mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-12 10:10:30 +03:00
replace deprecated optparse with argparse
following guidelines from: https://docs.python.org/2/library/argparse.html#upgrading-optparse-code except, still using option = parse.parse_args() instead of args = ... - using the following script in folder fdroidserver: for i in *.py; do sed -i -e 's/optparse/argparse/' \ -e 's/OptionParser/ArgumentParser/' \ -e 's/OptionError/ArgumentError/' \ -e 's/add_option/add_argument/' \ -e 's/(options, args) = parser/options = parser/' \ -e 's/options, args = parser/options = parser/' \ -e 's/Usage: %prog/%(prog)s/' $i; done - use ArgumentParser argument to replace (option, args) = parser.parse() call - use parser.error(msg) instead of raise ArgumentException as suggested in https://docs.python.org/2/library/argparse.html#exiting-methods - in fdroid catch ArgumentError instead of OptionError
This commit is contained in:
parent
41443edd55
commit
d23ecf1b35
17 changed files with 232 additions and 227 deletions
4
fdroid
4
fdroid
|
|
@ -22,7 +22,7 @@ import sys
|
|||
import logging
|
||||
|
||||
import fdroidserver.common
|
||||
from optparse import OptionError
|
||||
from argparse import ArgumentError
|
||||
|
||||
commands = {
|
||||
"build": "Build a package from source",
|
||||
|
|
@ -124,7 +124,7 @@ def main():
|
|||
else:
|
||||
logging.critical(str(e))
|
||||
sys.exit(1)
|
||||
except OptionError, e:
|
||||
except ArgumentError as e:
|
||||
logging.critical(str(e))
|
||||
sys.exit(1)
|
||||
except KeyboardInterrupt:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue