Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 100 lines (85 sloc) 2.413 kb
df3ae42c » Steve Conklin
2010-12-18 Added development files
1 #!/usr/bin/env python
2
3 # Copyright 2009 Steve Conklin
4 # steve at conklinhouse dot com
5 #
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; either version 2
9 # of the License, or (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
20 #
21 # Pattern Number
22 # Position of the selector
23 # Pattern position for the selector setting
24 # Pattern position and number of repeats for each motif for selector (2) settings
25 # Variation key settings
26 # Memo display information
27 # Row numbers and memo key information
28
29 # 200 needles
30 # pattern position is Yellow or Green (left or right)
31 # up to 6 motifs -
32
33 import sys
34 from struct import *
35 from collections import namedtuple
36 #import os
37 #import os.path
38 #import string
39 #from array import *
40
41 def dumpPattern(pat):
42 bits = []
43 for short in pat:
44 for i in range(15, -1, -1):
45 mask = (2 ** i)
46 if short & (2 ** i):
47 bits.append('*')
48 else:
49 bits.append(' ')
50 print "".join(bits)
51 return
52
53
54 if len(sys.argv) < 3:
55 print 'Usage: %s fileA fileB' % sys.argv[0]
56 sys.exit()
57
58 f1 = open(sys.argv[1])
59 #f2 = open(sys.argv[2])
60
61 d1 = f1.read(2048)
62 #d2 = f2.read(2048)
63
64 # head - 1766 bytes
65 fmt = '1766B'
66 # first pattern
67 fmt += '13H'
68 # after first pattern
69 fmt += '22B'
70
71
72 # second pattern
73 fmt += '13H'
74 # tail
75 fmt += '208B'
76
77
78 #lead, pattern1, dummy, pattern2, tail = struct.unpack(fmt, d1)
79 #lead[1766], pattern1[13], dummy[22], pattern2[13], tail[208] = unpack(fmt, d1)
80 foo = unpack(fmt, d1)
81 print len(foo)
82 #bar = foo[0:1766]
83 baz = foo[1766:1779]
84 dumpPattern(baz)
85 #print bar
86 #print baz
87 #print foo
88
89 #inrun = False
90 #for i in range(len(d1)):
91 # if d1[i] != d2[i]:
92 # if not inrun:
93 # print '--'
94 # inrun = True
95 # print '%04X: %02X %02X' % (i, ord(d1[i]), ord(d2[i]))
96 # else:
97 # inrun = False
98 #
99 #f1.close()
100 #f2.close()
Something went wrong with that request. Please try again.