Return to Snippet

Revision: 55945
at March 1, 2012 09:08 by miceno


Initial Code
logging.basicConfig()
    parser = OptionParser(usage="%prog [-f] [-q] <free-form date string>", version=str(__version__))
    parser.add_option("-f", "--force-update",
                      action='store_true', dest="force_update", default=False,
                      help="force self-updating of TRANSLATION_DICT in this file", metavar="FILE")
    parser.add_option("-q", "--quiet",
                      action="store_false", dest="verbose", default=True,
                      help="don't print debug messages to stdout")
    (options, args) = parser.parse_args()
    if len(args) != 1:
        parser.error("you have missed query string")
    date_string = args[0]
    if options.verbose:
        print '%s -> %s' % (date_string, parse(date_string, loglevel=logging.DEBUG, force_update=options.force_update))
    else:
        print parse(date_string, loglevel=logging.WARNING, force_update=options.force_update)

Initial URL

                                

Initial Description
Parsing arguments in Python

Initial Title
Parsing arguments in Python

Initial Tags

                                

Initial Language
Python