mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-16 16:02:33 +03:00
metadata: simplify _app_to_yaml()
There are some redundant checks and odd construct: * cm.update({a: b}) --> cm[a] = b * getattr(app, field) --> app.get(field)
This commit is contained in:
parent
2cb12f9594
commit
e8ab84b583
1 changed files with 9 additions and 10 deletions
|
@ -1100,22 +1100,21 @@ def _app_to_yaml(app):
|
||||||
# next iteration will need to insert a newline
|
# next iteration will need to insert a newline
|
||||||
insert_newline = True
|
insert_newline = True
|
||||||
else:
|
else:
|
||||||
if app.get(field) or field == 'Builds':
|
value = app.get(field)
|
||||||
|
if value or field == 'Builds':
|
||||||
if field == 'Builds':
|
if field == 'Builds':
|
||||||
if app.get('Builds'):
|
if app.get('Builds'):
|
||||||
cm.update({field: _builds_to_yaml(app)})
|
cm.update({field: _builds_to_yaml(app)})
|
||||||
elif field == 'CurrentVersionCode':
|
elif field == 'CurrentVersionCode':
|
||||||
cm.update({field: _field_to_yaml(TYPE_INT, getattr(app, field))})
|
cm[field] = _field_to_yaml(TYPE_INT, value)
|
||||||
elif field == 'AllowedAPKSigningKeys':
|
elif field == 'AllowedAPKSigningKeys':
|
||||||
value = getattr(app, field)
|
|
||||||
if value:
|
|
||||||
value = [str(i).lower() for i in value]
|
value = [str(i).lower() for i in value]
|
||||||
if len(value) == 1:
|
if len(value) == 1:
|
||||||
cm.update({field: _field_to_yaml(TYPE_STRING, value[0])})
|
cm[field] = _field_to_yaml(TYPE_STRING, value[0])
|
||||||
else:
|
else:
|
||||||
cm.update({field: _field_to_yaml(TYPE_LIST, value)})
|
cm[field] = _field_to_yaml(TYPE_LIST, value)
|
||||||
else:
|
else:
|
||||||
cm.update({field: _field_to_yaml(fieldtype(field), getattr(app, field))})
|
cm[field] = _field_to_yaml(fieldtype(field), value)
|
||||||
|
|
||||||
if insert_newline:
|
if insert_newline:
|
||||||
# we need to prepend a newline in front of this field
|
# we need to prepend a newline in front of this field
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue