From 902f1307dc0c5ae0ef5b829da19bc70e74ae4592 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20P=C3=B6hn?= Date: Wed, 24 Jul 2019 16:54:15 +0200 Subject: [PATCH] rewritemeta: refactor supported list to module variable SUPPORTED_FORMATS --- fdroidserver/rewritemeta.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/fdroidserver/rewritemeta.py b/fdroidserver/rewritemeta.py index 0cc5c416..97d15852 100644 --- a/fdroidserver/rewritemeta.py +++ b/fdroidserver/rewritemeta.py @@ -30,6 +30,9 @@ config = None options = None +SUPPORTED_FORMATS = ['txt', 'yml'] + + def proper_format(app): s = io.StringIO() # TODO: currently reading entire file again, should reuse first @@ -50,15 +53,13 @@ def main(): global config, options - supported = ['txt', 'yml'] - # Parse command line... parser = ArgumentParser(usage="%(prog)s [options] [APPID [APPID ...]]") common.setup_global_opts(parser) parser.add_argument("-l", "--list", action="store_true", default=False, help=_("List files that would be reformatted")) parser.add_argument("-t", "--to", default=None, - help=_("Rewrite to a specific format: ") + ', '.join(supported)) + help=_("Rewrite to a specific format: ") + ', '.join(SUPPORTED_FORMATS)) parser.add_argument("appid", nargs='*', help=_("applicationId in the form APPID")) metadata.add_metadata_arguments(parser) options = parser.parse_args() @@ -73,14 +74,14 @@ def main(): if options.list and options.to is not None: parser.error(_("Cannot use --list and --to at the same time")) - if options.to is not None and options.to not in supported: + if options.to is not None and options.to not in SUPPORTED_FORMATS: parser.error(_("Unsupported metadata format, use: --to [{supported}]") - .format(supported=' '.join(supported))) + .format(supported=' '.join(SUPPORTED_FORMATS))) for appid, app in apps.items(): path = app.metadatapath base, ext = common.get_extension(path) - if not options.to and ext not in supported: + if not options.to and ext not in SUPPORTED_FORMATS: logging.info(_("Ignoring {ext} file at '{path}'").format(ext=ext, path=path)) continue elif options.to is not None: