@@ -0,0 +1,1684 @@
+#!/usr/bin/env python%0A%0Aimport sys%0Aimport optparse%0A%0Afrom pfile_tools import headers, struct_utils%0A%0Adef known_revisions():%0A    return sorted(headers.REVISIONS().keys())%0A%0A%0Adef build_option_parser():%0A    revision_opt_strs = %22, %22.join(%5Bstr(r) for r in known_revisions()%5D)%0A    p = optparse.OptionParser(%0A        usage=%22usage: %25prog %5BOPTIONS%5D pfile%22,%0A        description=%22Dumps header information from a GE P-file%22)%0A    p.add_option(%0A        %22-r%22, %22--revision%22, action=%22store%22, choices=known_revisions(),%0A        help=%22Force a header revision (available: %25s)%22 %25 revision_opt_strs)%0A    p.add_option(%0A        %22--offsets%22, action=%22store_true%22, default=False, dest=%22offsets%22,%0A        help=%22Show offsets to data elements%22)%0A    p.add_option(%0A        %22--sizes%22, action=%22store_true%22, default=False, dest=%22sizes%22,%0A        help=%22Show data element sizes%22)%0A    p.add_option(%0A        %22--show-padding%22, action=%22store_true%22, default=False, dest=%22padding%22,%0A        help=%22Print unknown 'padding' elements%22)%0A    return p%0A%0A%0Adef main():%0A    parser = build_option_parser()%0A    opts, args = parser.parse_args()%0A    if len(args) %3C 1:%0A        parser.error(%22Must specify a p-file.%22)%0A    rev = opts.revision%0A    if rev is not None:%0A        rev = int(rev)%0A    ph = headers.Pfile.from_file(args%5B0%5D, force_revision=rev)%0A    dumped = struct_utils.dump_struct(ph.header)%0A    for info in dumped:%0A        if (info.label.find(%22pad%22) == 0) and not opts.padding:%0A            continue%0A        s = %22%25s: %25s%22 %25 (info.label, info.value)%0A        if opts.offsets:%0A            s += %22 offset: %25#x%22 %25 (info.offset)%0A        if opts.sizes:%0A            s += %22 size: %25s%22 %25 (info.size)%0A        print(s)%0A%0A%0Aif __name__ == %22__main__%22:%0A    main()

Add friendly header dumper program.