Ejemplo n.º 1
0
def parseOptions():
    parser = OptionParser(usage="%prog [options] "
                          "pattern filename [filename2 ...]")

    common = OptionGroup(parser, "Grep", "Option of grep")
    common.add_option("--percent",
                      help="Display percent",
                      action="store_true",
                      default=False)
    common.add_option("--no-addr",
                      help="Don't display address",
                      action="store_true",
                      default=False)
    common.add_option("--no-value",
                      help="Don't display value",
                      action="store_true",
                      default=False)
    common.add_option("--case",
                      help="Search is case sensitive",
                      action="store_true",
                      default=False)
    common.add_option("--path",
                      help="Display path",
                      action="store_true",
                      default=False)
    common.add_option("--all",
                      help="Match all (just extract strings)",
                      action="store_true",
                      default=False)
    common.add_option("--bench",
                      help="Run benchmark",
                      action="store_true",
                      default=False)
    common.add_option("--version",
                      help="Display version and exit",
                      action="callback",
                      callback=displayVersion)
    parser.add_option_group(common)

    hachoir = getHachoirOptions(parser)
    parser.add_option_group(hachoir)

    values, arguments = parser.parse_args()
    if values.all or values.bench:
        if len(arguments) < 1:
            parser.print_help()
            sys.exit(1)
        pattern = None
        filenames = arguments
    else:
        if len(arguments) < 2:
            parser.print_help()
            sys.exit(1)
        pattern = str(arguments[0], "ascii")
        filenames = arguments[1:]
    return values, pattern, filenames
Ejemplo n.º 2
0
def parseOptions():
    parser = OptionParser(usage="%prog [options] [filename]")
    hachoir = getHachoirOptions(parser)
    parser.add_option_group(hachoir)

    values, arguments = parser.parse_args()
    if len(arguments) == 1:
        filename = arguments[0]
    elif not arguments:
        filename = None
    else:
        parser.print_help()
        sys.exit(1)
    return values, filename
Ejemplo n.º 3
0
def parseOptions():
    parser = OptionParser(usage="%prog [options] filename")

    common = OptionGroup(parser, "Urwid", "Option of urwid explorer")
    common.add_option("--preload",
                      help="Number of fields to preload at each read",
                      type="int",
                      action="store",
                      default=15)
    common.add_option("--path",
                      help="Initial path to focus on",
                      type="str",
                      action="store",
                      default=None)
    common.add_option("--parser",
                      help="Use the specified parser (use its identifier)",
                      type="str",
                      action="store",
                      default=None)
    common.add_option("--offset",
                      help="Skip first bytes of input file",
                      type="long",
                      action="store",
                      default=0)
    common.add_option("--parser-list",
                      help="List all parsers then exit",
                      action="callback",
                      callback=displayParserList)
    common.add_option("--profiler",
                      help="Run profiler",
                      action="store_true",
                      default=False)
    common.add_option("--profile-display",
                      help="Force update of the screen beetween each event",
                      action="store_true",
                      default=False)
    common.add_option("--size",
                      help="Maximum size of bytes of input file",
                      type="long",
                      action="store",
                      default=None)
    common.add_option("--hide-value",
                      dest="display_value",
                      help="Don't display value",
                      action="store_false",
                      default=True)
    common.add_option("--hide-size",
                      dest="display_size",
                      help="Don't display size",
                      action="store_false",
                      default=True)
    common.add_option("--version",
                      help="Display version and exit",
                      action="callback",
                      callback=displayVersion)
    parser.add_option_group(common)

    hachoir = getHachoirOptions(parser)
    parser.add_option_group(hachoir)

    values, arguments = parser.parse_args()
    if len(arguments) != 1:
        parser.print_help()
        sys.exit(1)
    return values, arguments[0]