From 576da1d04833374c75d51b16c63872440a1c2ed2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Fri, 11 Sep 2015 23:42:50 -0700 Subject: [PATCH] all: deduplicate -v/-q setup --- fdroidserver/build.py | 5 +---- fdroidserver/checkupdates.py | 5 +---- fdroidserver/common.py | 7 +++++++ fdroidserver/gpgsign.py | 5 +---- fdroidserver/import.py | 5 +---- fdroidserver/init.py | 5 +---- fdroidserver/install.py | 5 +---- fdroidserver/lint.py | 5 +---- fdroidserver/publish.py | 5 +---- fdroidserver/readmeta.py | 5 +---- fdroidserver/rewritemeta.py | 5 +---- fdroidserver/scanner.py | 5 +---- fdroidserver/server.py | 5 +---- fdroidserver/signindex.py | 5 +---- fdroidserver/stats.py | 5 +---- fdroidserver/update.py | 5 +---- fdroidserver/verify.py | 5 +---- 17 files changed, 23 insertions(+), 64 deletions(-) diff --git a/fdroidserver/build.py b/fdroidserver/build.py index 84734426..23ed8c20 100644 --- a/fdroidserver/build.py +++ b/fdroidserver/build.py @@ -935,11 +935,8 @@ def parse_commandline(): """Parse the command line. Returns options, parser.""" parser = ArgumentParser(usage="%(prog)s [options] [APPID[:VERCODE] [APPID[:VERCODE] ...]]") + common.setup_global_opts(parser) parser.add_argument("appid", nargs='*', help="app-id with optional versioncode in the form APPID[:VERCODE]") - 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("-l", "--latest", action="store_true", default=False, help="Build only the latest version of each package") parser.add_argument("-s", "--stop", action="store_true", default=False, diff --git a/fdroidserver/checkupdates.py b/fdroidserver/checkupdates.py index 78648410..99db8bbc 100644 --- a/fdroidserver/checkupdates.py +++ b/fdroidserver/checkupdates.py @@ -527,11 +527,8 @@ def main(): # Parse command line... parser = ArgumentParser(usage="%(prog)s [options] [APPID [APPID ...]]") + common.setup_global_opts(parser) 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, diff --git a/fdroidserver/common.py b/fdroidserver/common.py index 3feaf07a..becd3568 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -91,6 +91,13 @@ default_config = { } +def setup_global_opts(parser): + 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") + + def fill_config_defaults(thisconfig): for k, v in default_config.items(): if k not in thisconfig: diff --git a/fdroidserver/gpgsign.py b/fdroidserver/gpgsign.py index 8fca41cd..15c4deeb 100644 --- a/fdroidserver/gpgsign.py +++ b/fdroidserver/gpgsign.py @@ -36,10 +36,7 @@ def main(): # Parse command line... parser = ArgumentParser(usage="%(prog)s [options]") - 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") + common.setup_global_opts(parser) options = parser.parse_args() config = common.read_config(options) diff --git a/fdroidserver/import.py b/fdroidserver/import.py index 1debd216..eddb3238 100644 --- a/fdroidserver/import.py +++ b/fdroidserver/import.py @@ -158,10 +158,7 @@ def main(): # Parse command line... parser = ArgumentParser() - 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") + common.setup_global_opts(parser) parser.add_argument("-u", "--url", default=None, help="Project URL to import from.") parser.add_argument("-s", "--subdir", default=None, diff --git a/fdroidserver/init.py b/fdroidserver/init.py index cf75b911..3474fba1 100644 --- a/fdroidserver/init.py +++ b/fdroidserver/init.py @@ -51,10 +51,7 @@ def main(): # Parse command line... parser = ArgumentParser() - 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") + common.setup_global_opts(parser) parser.add_argument("-d", "--distinguished-name", default=None, help="X.509 'Distiguished Name' used when generating keys") parser.add_argument("--keystore", default=None, diff --git a/fdroidserver/install.py b/fdroidserver/install.py index 5339319f..766cd6a0 100644 --- a/fdroidserver/install.py +++ b/fdroidserver/install.py @@ -50,11 +50,8 @@ def main(): # Parse command line... parser = ArgumentParser(usage="%(prog)s [options] [APPID[:VERCODE] [APPID[:VERCODE] ...]]") + common.setup_global_opts(parser) parser.add_argument("appid", nargs='*', help="app-id with optional versioncode in the form APPID[:VERCODE]") - 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("-a", "--all", action="store_true", default=False, help="Install all signed applications available") options = parser.parse_args() diff --git a/fdroidserver/lint.py b/fdroidserver/lint.py index 7291a407..fb2ce2c0 100644 --- a/fdroidserver/lint.py +++ b/fdroidserver/lint.py @@ -307,11 +307,8 @@ def main(): # Parse command line... parser = ArgumentParser(usage="%(prog)s [options] [APPID [APPID ...]]") + common.setup_global_opts(parser) parser.add_argument("appid", nargs='*', help="app-id in the form APPID") - 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") options = parser.parse_args() config = common.read_config(options) diff --git a/fdroidserver/publish.py b/fdroidserver/publish.py index 0ef5b60d..74f16206 100644 --- a/fdroidserver/publish.py +++ b/fdroidserver/publish.py @@ -41,11 +41,8 @@ def main(): # Parse command line... parser = ArgumentParser(usage="%(prog)s [options] " "[APPID[:VERCODE] [APPID[:VERCODE] ...]]") + common.setup_global_opts(parser) parser.add_argument("appid", nargs='*', help="app-id with optional versioncode in the form APPID[:VERCODE]") - 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") options = parser.parse_args() config = common.read_config(options) diff --git a/fdroidserver/readmeta.py b/fdroidserver/readmeta.py index a01a358f..f3fa12c0 100644 --- a/fdroidserver/readmeta.py +++ b/fdroidserver/readmeta.py @@ -25,10 +25,7 @@ import metadata def main(): parser = ArgumentParser(usage="%(prog)s") - 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") + common.setup_global_opts(parser) parser.parse_args() common.read_config(None) diff --git a/fdroidserver/rewritemeta.py b/fdroidserver/rewritemeta.py index 6c748f2b..47e478a4 100644 --- a/fdroidserver/rewritemeta.py +++ b/fdroidserver/rewritemeta.py @@ -34,11 +34,8 @@ def main(): # Parse command line... parser = ArgumentParser(usage="%(prog)s [options] [APPID [APPID ...]]") + common.setup_global_opts(parser) parser.add_argument("appid", nargs='*', help="app-id in the form APPID") - 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") options = parser.parse_args() config = common.read_config(options) diff --git a/fdroidserver/scanner.py b/fdroidserver/scanner.py index fc15569b..15a25219 100644 --- a/fdroidserver/scanner.py +++ b/fdroidserver/scanner.py @@ -250,11 +250,8 @@ def main(): # Parse command line... parser = ArgumentParser(usage="%(prog)s [options] [APPID[:VERCODE] [APPID[:VERCODE] ...]]") + common.setup_global_opts(parser) parser.add_argument("appid", nargs='*', help="app-id with optional versioncode in the form APPID[:VERCODE]") - 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") options = parser.parse_args() config = common.read_config(options) diff --git a/fdroidserver/server.py b/fdroidserver/server.py index 114e8a80..802cac22 100644 --- a/fdroidserver/server.py +++ b/fdroidserver/server.py @@ -196,6 +196,7 @@ def main(): # Parse command line... parser = ArgumentParser() + common.setup_global_opts(parser) parser.add_argument("command", help="command to execute, either 'init' or 'update'") parser.add_argument("-i", "--identity-file", default=None, help="Specify an identity file to provide to SSH for rsyncing") @@ -203,10 +204,6 @@ def main(): help="Specify a local folder to sync the repo to") parser.add_argument("--sync-from-local-copy-dir", action="store_true", default=False, help="Before uploading to servers, sync from local copy dir") - 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("--no-checksum", action="store_true", default=False, help="Don't use rsync checksums") options = parser.parse_args() diff --git a/fdroidserver/signindex.py b/fdroidserver/signindex.py index e3645278..9b571a20 100644 --- a/fdroidserver/signindex.py +++ b/fdroidserver/signindex.py @@ -35,10 +35,7 @@ def main(): # Parse command line... parser = ArgumentParser(usage="%(prog)s [options]") - 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") + common.setup_global_opts(parser) options = parser.parse_args() config = common.read_config(options) diff --git a/fdroidserver/stats.py b/fdroidserver/stats.py index a4f7cf16..80b152c9 100644 --- a/fdroidserver/stats.py +++ b/fdroidserver/stats.py @@ -51,10 +51,7 @@ def main(): # Parse command line... parser = ArgumentParser() - 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") + common.setup_global_opts(parser) parser.add_argument("-d", "--download", action="store_true", default=False, help="Download logs we don't have") parser.add_argument("--recalc", action="store_true", default=False, diff --git a/fdroidserver/update.py b/fdroidserver/update.py index c3fba05b..9d54b20e 100644 --- a/fdroidserver/update.py +++ b/fdroidserver/update.py @@ -1049,16 +1049,13 @@ def main(): # Parse command line... parser = ArgumentParser() + common.setup_global_opts(parser) parser.add_argument("--create-key", action="store_true", default=False, help="Create a repo signing key in a keystore") parser.add_argument("-c", "--create-metadata", action="store_true", default=False, help="Create skeleton metadata files that are missing") parser.add_argument("--delete-unknown", action="store_true", default=False, help="Delete APKs without metadata from the repo") - 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("-b", "--buildreport", action="store_true", default=False, help="Report on build data status") parser.add_argument("-i", "--interactive", default=False, action="store_true", diff --git a/fdroidserver/verify.py b/fdroidserver/verify.py index 0e2f1962..d8373eb0 100644 --- a/fdroidserver/verify.py +++ b/fdroidserver/verify.py @@ -37,11 +37,8 @@ def main(): # Parse command line... parser = ArgumentParser(usage="%(prog)s [options] [APPID[:VERCODE] [APPID[:VERCODE] ...]]") + common.setup_global_opts(parser) parser.add_argument("appid", nargs='*', help="app-id with optional versioncode in the form APPID[:VERCODE]") - 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") options = parser.parse_args() config = common.read_config(options)