#!/usr/bin/env python3
PREAMBLE= '''
HexDump
Fabulous HexDump
'''
FOOTER= '''
'''
LINE_FMT= '{:04x}{}
'
def read_binary(name):
with open(name, 'rb') as fd:
return(fd.read())
def hexdump_html(binary):
def to_chunks(src, chunk_size):
idx= 0
end= len(src)
while idx{:02x}'.format(
int(byte/255*330), byte
)
for byte in chunk
)
html= LINE_FMT.format(index, as_hex)
yield(html)
rom= read_binary('25_flash_dump.bin')
with open('hex.html', 'w') as fd:
fd.write(PREAMBLE)
for line in hexdump_html(rom):
fd.write(line + '\n')
fd.write(FOOTER)