mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-04 22:40:29 +03:00
rewritemeta: refactor supported list to module variable SUPPORTED_FORMATS
This commit is contained in:
parent
08acb55897
commit
902f1307dc
1 changed files with 7 additions and 6 deletions
|
|
@ -30,6 +30,9 @@ config = None
|
||||||
options = None
|
options = None
|
||||||
|
|
||||||
|
|
||||||
|
SUPPORTED_FORMATS = ['txt', 'yml']
|
||||||
|
|
||||||
|
|
||||||
def proper_format(app):
|
def proper_format(app):
|
||||||
s = io.StringIO()
|
s = io.StringIO()
|
||||||
# TODO: currently reading entire file again, should reuse first
|
# TODO: currently reading entire file again, should reuse first
|
||||||
|
|
@ -50,15 +53,13 @@ def main():
|
||||||
|
|
||||||
global config, options
|
global config, options
|
||||||
|
|
||||||
supported = ['txt', 'yml']
|
|
||||||
|
|
||||||
# Parse command line...
|
# Parse command line...
|
||||||
parser = ArgumentParser(usage="%(prog)s [options] [APPID [APPID ...]]")
|
parser = ArgumentParser(usage="%(prog)s [options] [APPID [APPID ...]]")
|
||||||
common.setup_global_opts(parser)
|
common.setup_global_opts(parser)
|
||||||
parser.add_argument("-l", "--list", action="store_true", default=False,
|
parser.add_argument("-l", "--list", action="store_true", default=False,
|
||||||
help=_("List files that would be reformatted"))
|
help=_("List files that would be reformatted"))
|
||||||
parser.add_argument("-t", "--to", default=None,
|
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"))
|
parser.add_argument("appid", nargs='*', help=_("applicationId in the form APPID"))
|
||||||
metadata.add_metadata_arguments(parser)
|
metadata.add_metadata_arguments(parser)
|
||||||
options = parser.parse_args()
|
options = parser.parse_args()
|
||||||
|
|
@ -73,14 +74,14 @@ def main():
|
||||||
if options.list and options.to is not None:
|
if options.list and options.to is not None:
|
||||||
parser.error(_("Cannot use --list and --to at the same time"))
|
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}]")
|
parser.error(_("Unsupported metadata format, use: --to [{supported}]")
|
||||||
.format(supported=' '.join(supported)))
|
.format(supported=' '.join(SUPPORTED_FORMATS)))
|
||||||
|
|
||||||
for appid, app in apps.items():
|
for appid, app in apps.items():
|
||||||
path = app.metadatapath
|
path = app.metadatapath
|
||||||
base, ext = common.get_extension(path)
|
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))
|
logging.info(_("Ignoring {ext} file at '{path}'").format(ext=ext, path=path))
|
||||||
continue
|
continue
|
||||||
elif options.to is not None:
|
elif options.to is not None:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue