- Notifications
You must be signed in to change notification settings - Fork399
Open
Labels
Milestone
Description
Point of concern
PEP 389 states the gradual depreciation of Python'soptparse argument parsing library.
grepping the codebase, MyPaint uses optparse in three files:
Lines 244 to 290 in00483b9
defparsed_cmdline_arguments(default_confpath,debug=False): | |
"""Parse command line arguments and return result | |
:return: (options, positional arguments) | |
""" | |
parser=OptionParser("usage: %prog [options] [FILE]") | |
parser.add_option( | |
"-c", | |
"--config", | |
metavar="DIR", | |
default=default_confpath, | |
help="use old-style merged config directory DIR, e.g. ~/.mypaint", | |
) | |
parser.add_option( | |
"-l", | |
"--logfile", | |
metavar="FILE", | |
default=None, | |
help="log console messages to FILE (rel. to config location)", | |
) | |
parser.add_option( | |
"-t", | |
"--trace", | |
action="store_true", | |
help="print all executed Python statements", | |
) | |
parser.add_option( | |
"-f", | |
"--fullscreen", | |
action="store_true", | |
help="start in fullscreen mode", | |
) | |
parser.add_option( | |
"-V", | |
"--version", | |
action="store_true", | |
help="print version information and exit", | |
) | |
ifdebug: | |
parser.add_option( | |
"-R", | |
"--run-and-quit", | |
action="store_true", | |
help="start the program and shut it down after 1 second", | |
) | |
returnparser.parse_args(sys.argv_unicode[1:]) |
mypaint/tests/unported/memory_leak.py
Lines 216 to 257 in00483b9
fromoptparseimportOptionParser | |
parser=OptionParser("usage: %prog [options] [test1 test2 test3 ...]") | |
parser.add_option( | |
"-a","--all",action="store_true",default=False,help="run all tests" | |
) | |
parser.add_option( | |
"-l", | |
"--list", | |
action="store_true", | |
default=False, | |
help="list all available tests", | |
) | |
parser.add_option( | |
"-d", | |
"--debug", | |
action="store_true", | |
default=False, | |
help="print leak analysis (slow)", | |
) | |
parser.add_option( | |
"-e", | |
"--exit", | |
action="store_true", | |
default=False, | |
help="exit at first error", | |
) | |
parser.add_option( | |
"-r", | |
"--required", | |
type="int", | |
default=15, | |
help="iterations required to draw a conclusion (default: 15)", | |
) | |
parser.add_option( | |
"-m", | |
"--max-iterations", | |
type="int", | |
default=100, | |
help="maximum number of iterations (default: 100)", | |
) | |
options,tests=parser.parse_args() |
mypaint/tests/unported/performance.py
Lines 345 to 379 in00483b9
fromoptparseimportOptionParser | |
parser=OptionParser("usage: %prog [options] [test1 test2 test3 ...]") | |
parser.add_option( | |
"-a","--all",action="store_true",default=False,help="run all tests" | |
) | |
parser.add_option( | |
"-l", | |
"--list", | |
action="store_true", | |
default=False, | |
help="list all available tests", | |
) | |
parser.add_option( | |
"-c", | |
"--count", | |
metavar="N", | |
type="int", | |
default=3, | |
help="number of repetitions (default: 3)", | |
) | |
parser.add_option( | |
"-p", | |
"--profile", | |
metavar="PREFIX", | |
help="dump cProfile info to PREFIX_TESTNAME_N.pstats", | |
) | |
parser.add_option( | |
"-s", | |
"--show-profile", | |
action="store_true", | |
default=False, | |
help="run cProfile, gprof2dot.py and show last result", | |
) | |
options,tests=parser.parse_args() |
Suggested improvements
Replace optparse with argparse