mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-10-02 09:10:11 +02: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
@ -1100,22 +1100,21 @@ def _app_to_yaml(app):
|
||||
# next iteration will need to insert a newline
|
||||
insert_newline = True
|
||||
else:
|
||||
if app.get(field) or field == 'Builds':
|
||||
value = app.get(field)
|
||||
if value or field == 'Builds':
|
||||
if field == 'Builds':
|
||||
if app.get('Builds'):
|
||||
cm.update({field: _builds_to_yaml(app)})
|
||||
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':
|
||||
value = getattr(app, field)
|
||||
if value:
|
||||
value = [str(i).lower() for i in value]
|
||||
if len(value) == 1:
|
||||
cm.update({field: _field_to_yaml(TYPE_STRING, value[0])})
|
||||
cm[field] = _field_to_yaml(TYPE_STRING, value[0])
|
||||
else:
|
||||
cm.update({field: _field_to_yaml(TYPE_LIST, value)})
|
||||
cm[field] = _field_to_yaml(TYPE_LIST, value)
|
||||
else:
|
||||
cm.update({field: _field_to_yaml(fieldtype(field), getattr(app, field))})
|
||||
cm[field] = _field_to_yaml(fieldtype(field), value)
|
||||
|
||||
if insert_newline:
|
||||
# we need to prepend a newline in front of this field
|
||||
|
Loading…
Reference in New Issue
Block a user