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