# HG changeset patch # User Thierry Florac # Date 1460389072 -7200 # Node ID c7f27ae4230df1706dbb236bac52e5d995e69c35 # Parent 01de65ad00fb5c4716f4d67d01009f3e622bca9e Replace "optparse" package with "argparse" diff -r 01de65ad00fb -r c7f27ae4230d src/pyams_utils/scripts/zodb.py --- a/src/pyams_utils/scripts/zodb.py Mon Apr 11 17:37:23 2016 +0200 +++ b/src/pyams_utils/scripts/zodb.py Mon Apr 11 17:37:52 2016 +0200 @@ -14,7 +14,7 @@ # import standard library -import optparse +import argparse import sys import textwrap @@ -27,17 +27,16 @@ def upgrade_site(): """Check for site upgrade""" - usage = "usage: %prog config_uri" + usage = "usage: {0} config_uri".format(sys.argv[0]) description = """Check for database upgrade. Usage: pyams_upgrade production.ini """ - parser = optparse.OptionParser(usage=usage, - description=textwrap.dedent(description)) - options, args = parser.parse_args(sys.argv[1:]) - if not len(args) >= 1: - print("You must provide at least one configuration file") - return 2 - config_uri = args[0] + parser = argparse.ArgumentParser(usage=usage, + description=textwrap.dedent(description)) + parser.add_argument('config_uri', help='Name of configuration file') + args = parser.parse_args() + + config_uri = args.config_uri env = bootstrap(config_uri) settings, closer = env['registry'].settings, env['closer'] try: