Changeset 40 for trunk/bin/bletchley-analyze
- Timestamp:
- 03/17/13 22:26:27 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bin/bletchley-analyze
r35 r40 1 #!/usr/bin/env python 1 #!/usr/bin/env python3 2 2 3 # Requires Python 2.7+3 # Requires Python 3+ 4 4 5 5 ''' … … 54 54 sys.exit(0) 55 55 56 input_file = sys.stdin 56 input_file = sys.stdin.buffer 57 57 if options.input_file is not None: 58 input_file = file(options.input_file, 'rb')58 input_file = open(options.input_file, 'rb') 59 59 60 blobs = input_file.read().rstrip( '\n').replace('\r', '').split('\n')60 blobs = input_file.read().rstrip(b'\n').replace(b'\r', b'').split(b'\n') 61 61 #print(repr(blobs)) 62 62 … … 81 81 line_size = 64 82 82 group_size *= 2 # two hex digits per byte 83 hex_blobs = map(binascii.b2a_hex, blobs)83 hex_blobs = [binascii.b2a_hex(b) for b in blobs] 84 84 color_map = buffertools.blockWiseColorMap(group_size, hex_blobs) 85 85 86 86 for k in range(0,len(hex_blobs)): 87 hex = hex_blobs[k] 87 hex = hex_blobs[k].decode() 88 88 89 89 for i in range(0,len(hex),line_size): … … 98 98 99 99 line += '| ' 100 line += repr(blobs[k][i/ 2:(i+line_size)/2])100 line += repr(blobs[k][i//2:(i+line_size)//2]) 101 101 102 102 print(line) … … 136 136 encoding = specified_encodings.pop(0) 137 137 138 139 138 blobs_to_print = blobs[:options.output_lines] 140 139 print('First %d Values:' % len(blobs_to_print))
Note: See TracChangeset
for help on using the changeset viewer.