optparser was deprecated in py 2.7
https://docs.python.org/2/library/argparse.html#module-argparse
It is used by editarticle.py
Version: core-(2.0)
Severity: trivial
optparser was deprecated in py 2.7
https://docs.python.org/2/library/argparse.html#module-argparse
It is used by editarticle.py
Version: core-(2.0)
Severity: trivial
Subject | Repo | Branch | Lines +/- | |
---|---|---|---|---|
editarticle: move from optparse to argparse | pywikibot/core | master | +30 -15 |
Status | Subtype | Assigned | Task | ||
---|---|---|---|---|---|
Invalid | None | T72936 Important tasks to be solved (tracking) | |||
Resolved | Xqt | T60053 Pywikibot Python 3 compatibility (tracking) | |||
Resolved | Mloc-gci | T70617 editarticle uses deprecated optparser |
"Deprecated since version 3.2: The optparse module is deprecated and will not be developed further; development will continue with the argparse module."
Would that be a task suitable for Google Code-in and would somebody be willing to mentor a student? If so, feel free to add to https://www.mediawiki.org/wiki/Google_Code-in_2014#Proposed_tasks
The GCI task reads
Should that not be "replaced by handleArgs"?
No not really: handleArgs (or how it's now called handle_args) is already called (in line 46), but this request is about parsing the script specific parameters. And there are several ways to do that. Currently most scripts are doing it manually by iterating through the entries and then “doing it's stuff” but this is using optparse.
Now depending on how fast the argparse patch (https://gerrit.wikimedia.org/r/156089/) is going to be imported it would be better to just change the optparse into argparse. That is relatively easy and with that linked patch the adjustments are minimal.
Change 176747 had a related patch set uploaded (by Mloc-gci):
editarticle: move from optparse to argparse
The build with this change merged was successful.
https://travis-ci.org/wikimedia/pywikibot-core/builds/42813041
This script could now be used as an example implementation for T76429.