Debian Codegraph @

scripts/namesum.py

raw symbols SCIP
1 #
2 # Copyright (C) 2006 Steve Ratcliffe
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License version 2 as
6 # published by the Free Software Foundation.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 #
14 # Author: Steve Ratcliffe
15 # Create date: 11 Dec 2006
16 #
17
18 import sys
19 from imgfile import Imgfile
20
21 def main(name):
22
23 img = Imgfile(name)
24
25 bl = img.get_block(0)
26
27 ranges = [
28 (0x39, 0x5d),
29 (0x65, 0x84)
30 ]
31
32 sums = []
33 sn = 0
34
35 sum = 0
36 for r in ranges:
37 for i in xrange(r[0], r[1]):
38 b = ord(bl[i])
39 sum += b
40 sums.append( sum)
41 sum = 0
42 sn += 1
43
44 headb = img.get_block(2)
45 for i in xrange(0x20, 0x30, 2):
46 bn = headb[i]
47 bn = ord(bn)
48 if bn <= 2:
49 continue
50 if bn == 255:
51 break
52 bl = img.get_block(bn)
53 for i in xrange(0x20, 256):
54 b = ord(bl[i])
55 sum += b
56 sums.append(sum)
57 sum = 0
58 sn += 1
59
60 tot = 0
61 for sum in sums:
62 print hex(sum),
63 tot += sum
64
65 print 'tot', tot, hex(tot)
66 print
67 return
68
69
70
71 if __name__ == '__main__':
72 for name in sys.argv[1:]:
73 main(name)