mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-06 23:40:29 +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
|
|
@ -24,7 +24,7 @@ import re
|
|||
import urllib2
|
||||
import time
|
||||
import subprocess
|
||||
from optparse import OptionParser
|
||||
from argparse import ArgumentParser
|
||||
import traceback
|
||||
import HTMLParser
|
||||
from distutils.version import LooseVersion
|
||||
|
|
@ -515,27 +515,28 @@ def main():
|
|||
global config, options
|
||||
|
||||
# Parse command line...
|
||||
parser = OptionParser(usage="Usage: %prog [options] [APPID [APPID ...]]")
|
||||
parser.add_option("-v", "--verbose", action="store_true", default=False,
|
||||
help="Spew out even more information than normal")
|
||||
parser.add_option("-q", "--quiet", action="store_true", default=False,
|
||||
help="Restrict output to warnings and errors")
|
||||
parser.add_option("--auto", action="store_true", default=False,
|
||||
help="Process auto-updates")
|
||||
parser.add_option("--autoonly", action="store_true", default=False,
|
||||
help="Only process apps with auto-updates")
|
||||
parser.add_option("--commit", action="store_true", default=False,
|
||||
help="Commit changes")
|
||||
parser.add_option("--gplay", action="store_true", default=False,
|
||||
help="Only print differences with the Play Store")
|
||||
(options, args) = parser.parse_args()
|
||||
parser = ArgumentParser(usage="%(prog)s [options] [APPID [APPID ...]]")
|
||||
parser.add_argument("appid", nargs='*', help="app-id to check for updates")
|
||||
parser.add_argument("-v", "--verbose", action="store_true", default=False,
|
||||
help="Spew out even more information than normal")
|
||||
parser.add_argument("-q", "--quiet", action="store_true", default=False,
|
||||
help="Restrict output to warnings and errors")
|
||||
parser.add_argument("--auto", action="store_true", default=False,
|
||||
help="Process auto-updates")
|
||||
parser.add_argument("--autoonly", action="store_true", default=False,
|
||||
help="Only process apps with auto-updates")
|
||||
parser.add_argument("--commit", action="store_true", default=False,
|
||||
help="Commit changes")
|
||||
parser.add_argument("--gplay", action="store_true", default=False,
|
||||
help="Only print differences with the Play Store")
|
||||
options = parser.parse_args()
|
||||
|
||||
config = common.read_config(options)
|
||||
|
||||
# Get all apps...
|
||||
allapps = metadata.read_metadata()
|
||||
|
||||
apps = common.read_app_args(args, allapps, False)
|
||||
apps = common.read_app_args(options.appid, allapps, False)
|
||||
|
||||
if options.gplay:
|
||||
for app in apps:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue