def build_option_parser(): revision_opt_strs = ", ".join([str(r) for r in headers.known_revisions()]) p = optparse.OptionParser( usage="usage: %prog [OPTIONS] pfile", description="Dumps header information from a GE P-file", version="%prog " + pfile_tools.VERSION) p.add_option("-r", "--revision", action="store", choices=headers.known_revisions(), help="Force a header revision (available: %s)" % revision_opt_strs) p.add_option("--offsets", action="store_true", default=False, dest="offsets", help="Show offsets to data elements") p.add_option("--sizes", action="store_true", default=False, dest="sizes", help="Show data element sizes") p.add_option("--show-padding", action="store_true", default=False, dest="padding", help="Print unknown 'padding' elements") p.add_option("--separator", action="store", default="\t", help="Output field separator (default: \\t)") return p
def build_option_parser(anonymization_list): revision_opt_strs = ", ".join([str(r) for r in headers.known_revisions()]) p = optparse.OptionParser( usage="usage: %prog [OPTIONS] pfile pfile_out", description="Removes personally-identifying information from a GE P-file", version="%prog "+pfile_tools.VERSION) p.add_option( "-r", "--revision", action="store", choices=headers.known_revisions(), help="Force a header revision (available: %s)" % revision_opt_strs) p.add_option("--inplace", action="store_true", help="Edit file in-place. Ignores pfile_out.") p.add_option("-v", "--verbose", action="store_true", help="Print lots of extra debugging.") group = optparse.OptionGroup(p, "Anonymization options") for entry in anonymization_list: group.add_option( "--"+entry.option_name, action="store", type="choice", choices=["yes", "no"], default="yes", metavar="yes/no", help="Set %s to %r (yes)" % (entry.description, entry.value)) p.add_option_group(group) return p