1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-07-02 07:20:37 +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:
Hans-Christoph Steiner 2023-05-08 14:44:01 +02:00
parent 2cb12f9594
commit e8ab84b583

View File

@ -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])})
else:
cm.update({field: _field_to_yaml(TYPE_LIST, value)})
value = [str(i).lower() for i in value]
if len(value) == 1:
cm[field] = _field_to_yaml(TYPE_STRING, value[0])
else:
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