Source

hachoir / hachoir-wx / hachoir-wx

Full commit
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from hachoir_wx.app import app_t
from hachoir_wx.version import PACKAGE, VERSION, WEBSITE
from hachoir_core.cmd_line import (getHachoirOptions,
    configureHachoir, unicodeFilename)
from optparse import OptionParser
import sys

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

def main():
    print "%s version %s" % (PACKAGE, VERSION)
    print WEBSITE
    print
    values, filename = parseOptions()
    configureHachoir(values)
    app = app_t(filename)
    app.MainLoop()

if __name__ == '__main__':
    main()