metadata: work with dicts generated by standard YAML parsers

Now that the mismatch between 'builds' and 'Builds' has been fixed, it is
now possible to read metadata/*.yml files with a standard YAML parser like
PyYAML, then output them using `metadata.write_metadata()`.  Other API
functions in fdroidserver should also work in this case.

I did this as I was working on fdroiddata!7860
This commit is contained in:
Hans-Christoph Steiner 2020-12-09 19:27:37 +01:00
parent bf25b4ca03
commit e93acf7964

View file

@ -940,6 +940,8 @@ def write_yaml(mf, app):
def _builds_to_yaml(app): def _builds_to_yaml(app):
builds = ruamel.yaml.comments.CommentedSeq() builds = ruamel.yaml.comments.CommentedSeq()
for build in app.get('Builds', []): for build in app.get('Builds', []):
if not isinstance(build, Build):
build = Build(build)
b = ruamel.yaml.comments.CommentedMap() b = ruamel.yaml.comments.CommentedMap()
for field in build_flags: for field in build_flags:
value = getattr(build, field) value = getattr(build, field)