1#!/usr/bin/env python 2# vim: set expandtab ts=4 sw=4 tw=100: 3 4import sys 5from optparse import OptionParser 6 7parser = OptionParser() 8parser.add_option("-b", "--before", dest="before", action="append", 9 help="text to put before, may be specified more than once") 10parser.add_option("-a", "--after", dest="after", action="append", 11 help="text to put after, may be specified more than once") 12(options, args) = parser.parse_args() 13 14if options.before and len(options.before) > 0: 15 for b in options.before: 16 print b 17 18offset = 0 19f = bytearray(sys.stdin.read()) 20for c in f: 21 if offset != 0 and offset % 16 == 0: 22 print "" 23 print "%#04x," % c, 24 offset = offset + 1 25print "" 26 27if options.after and len(options.after) > 0: 28 for a in options.after: 29 print a 30 31