# HG changeset patch # User Magnus Schieder # Date 1517402094 -3600 # Node ID 193a4a0516600bcfe20c41c1ffe7271078daa434 # Parent 669766ad5477cbb7d2ed3926f14db9134e58d9e3 Version: bumps to 2.3.dev1, ptparse to argparse Migration. * Updates CHANGES diff -r 669766ad5477 -r 193a4a051660 CHANGES --- a/CHANGES Fri Jan 26 17:32:23 2018 +0100 +++ b/CHANGES Wed Jan 31 13:34:54 2018 +0100 @@ -1,3 +1,10 @@ +2.x 20xx-xx-xx UNRELEASED + + * optparse to argparse Migration. + The optparse module is deprecated and will not be developed further.The + development will continue with the argparse module. + Patch by Magnus Schieder + 2.2 2018-01-26 * The problem with unwanted multi moves and deletions is solved. diff -r 669766ad5477 -r 193a4a051660 getan/__init__.py --- a/getan/__init__.py Fri Jan 26 17:32:23 2018 +0100 +++ b/getan/__init__.py Wed Jan 31 13:34:54 2018 +0100 @@ -6,5 +6,5 @@ # This is Free Software licensed under the terms of GPLv3 or later. # For details see LICENSE coming with the source of 'getan'. -__version_info__ = ("2", "2") +__version_info__ = ("2", "3", "dev1") __version__ = '.'.join(__version_info__) diff -r 669766ad5477 -r 193a4a051660 getan/main.py --- a/getan/main.py Fri Jan 26 17:32:23 2018 +0100 +++ b/getan/main.py Wed Jan 31 13:34:54 2018 +0100 @@ -13,8 +13,7 @@ import logging import os import os.path - -from optparse import OptionParser +import argparse import getan import getan.config as config @@ -27,29 +26,37 @@ def main(): - usage = "usage: %prog [options] [databasefile (default: " + \ + usage = "%(prog)s [options] [databasefile (default: " + \ DEFAULT_DATABASE + ")]" version = "getan version %s" % getan.__version__ - parser = OptionParser(usage=usage, version=version) - parser.add_option("--init-only", action="store_true", dest="initonly", - help="create databasefile if necessary and exit") - parser.add_option("-d", "--debug", action="store_true", dest="debug", - help="set verbosity to debug") - parser.add_option("-l", "--logfile", dest="logfile", metavar="FILE", - help="write log information to FILE [default: %default]", - default="getan.log") - (options, args) = parser.parse_args() + + parser = argparse.ArgumentParser(prog='getan', usage=usage) + parser.add_argument('--version', action='version', version=version) + parser.add_argument(dest='filename', nargs='?', + help='[databasefile (default: time.db)]') + parser.add_argument('--init-only', action='store_true', dest='initonly', + help='create databasefile if necessary and exit') + parser.add_argument('-d', '--debug', action='store_true', dest='debug', + help='set verbosity to debug') + # Default value of the logfile name is defined in .getan/config.py. + parser.add_argument('-l', '--logfile', dest='logfile', metavar='FILE', + help='write log information to FILE [default: getan.log]', + nargs='?') + + args = parser.parse_args() + logargs = dict() - if options.debug: + + if args.debug: logargs["level"] = logging.DEBUG - if options.logfile: - logargs["filename"] = options.logfile + if args.logfile: + logargs["filename"] = args.logfile config.initialize(**logargs) global logger - if len(args) > 0: - backend = Backend(args[0]) - logging.info("Using database '%s'." % args[0]) + if args.filename != None : + backend = Backend(args.filename) + logging.info("Using database '%s'." % args.filename) else: if os.path.isfile(DEFAULT_DATABASE): database = os.path.abspath(DEFAULT_DATABASE) @@ -62,7 +69,7 @@ backend = Backend(database) logging.info("Using database '%s'." % database) - if options.initonly: + if args.initonly: return controller = GetanController(backend)