mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-06 23:40:29 +03:00
use pyyaml for rewriting .yml metadata files
This replaces the broken, custom code with the standard YAML lib. In rewritemeta, do not call app.metadatapath since it will be deleted when the dict is cleaned up for outputing. metadatapath is only used internally and should not be written out. closes #169 refs #290
This commit is contained in:
parent
e7e97654b1
commit
0d00705aed
2 changed files with 38 additions and 70 deletions
|
|
@ -72,9 +72,10 @@ def main():
|
|||
parser.error("Unsupported metadata format, use: --to [" + ' '.join(supported) + "]")
|
||||
|
||||
for appid, app in apps.items():
|
||||
base, ext = common.get_extension(app.metadatapath)
|
||||
path = app.metadatapath
|
||||
base, ext = common.get_extension(path)
|
||||
if not options.to and ext not in supported:
|
||||
logging.info("Ignoring %s file at '%s'" % (ext, app.metadatapath))
|
||||
logging.info("Ignoring %s file at '%s'" % (ext, path))
|
||||
continue
|
||||
|
||||
to_ext = ext
|
||||
|
|
@ -83,13 +84,24 @@ def main():
|
|||
|
||||
if options.list:
|
||||
if not proper_format(app):
|
||||
print(app.metadatapath)
|
||||
print(path)
|
||||
continue
|
||||
|
||||
newbuilds = []
|
||||
for build in app.builds:
|
||||
new = metadata.Build()
|
||||
for k in metadata.build_flags:
|
||||
v = build[k]
|
||||
if v is None or v is False or v == [] or v == '':
|
||||
continue
|
||||
new[k] = v
|
||||
newbuilds.append(new)
|
||||
app.builds = newbuilds
|
||||
|
||||
metadata.write_metadata(base + '.' + to_ext, app)
|
||||
|
||||
if ext != to_ext:
|
||||
os.remove(app.metadatapath)
|
||||
os.remove(path)
|
||||
|
||||
logging.debug("Finished.")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue