mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-13 22:42:29 +03:00
rewritemeta: add -l option to list files
This commit is contained in:
parent
911994fc99
commit
811fcd320f
2 changed files with 20 additions and 4 deletions
|
@ -184,8 +184,8 @@ __complete_readmeta() {
|
||||||
}
|
}
|
||||||
|
|
||||||
__complete_rewritemeta() {
|
__complete_rewritemeta() {
|
||||||
opts="-v -q"
|
opts="-v -q -l"
|
||||||
lopts="--verbose --quiet"
|
lopts="--verbose --quiet --list"
|
||||||
case "${cur}" in
|
case "${cur}" in
|
||||||
-*)
|
-*)
|
||||||
__complete_options
|
__complete_options
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
|
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
import logging
|
import logging
|
||||||
|
import StringIO
|
||||||
|
|
||||||
import common
|
import common
|
||||||
import metadata
|
import metadata
|
||||||
|
|
||||||
|
@ -34,6 +36,8 @@ def main():
|
||||||
# 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,
|
||||||
|
help="List files that would be reformatted")
|
||||||
parser.add_argument("appid", nargs='*', help="app-id in the form APPID")
|
parser.add_argument("appid", nargs='*', help="app-id in the form APPID")
|
||||||
options = parser.parse_args()
|
options = parser.parse_args()
|
||||||
|
|
||||||
|
@ -51,6 +55,18 @@ def main():
|
||||||
% (ext.upper(), metadatapath))
|
% (ext.upper(), metadatapath))
|
||||||
continue
|
continue
|
||||||
logging.debug("Rewriting " + metadatapath)
|
logging.debug("Rewriting " + metadatapath)
|
||||||
|
if options.list:
|
||||||
|
s = StringIO.StringIO()
|
||||||
|
# TODO: currently reading entire file again, should reuse first
|
||||||
|
# read in metadata.py
|
||||||
|
with open(metadatapath, 'r') as f:
|
||||||
|
cur_content = f.read()
|
||||||
|
metadata.write_metadata(s, app)
|
||||||
|
content = s.getvalue()
|
||||||
|
s.close()
|
||||||
|
if content != cur_content:
|
||||||
|
print(metadatapath)
|
||||||
|
else:
|
||||||
with open(metadatapath, 'w') as f:
|
with open(metadatapath, 'w') as f:
|
||||||
metadata.write_metadata(f, app)
|
metadata.write_metadata(f, app)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue