1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-08-17 20:00:10 +02:00

move metadata post-parse processing to reusable function

This commit is contained in:
Hans-Christoph Steiner 2015-07-22 01:12:21 -07:00
parent 9e5dd19fc8
commit eeb8ba02b0

View File

@ -577,6 +577,17 @@ def get_default_app_info_list():
return thisinfo
def post_metadata_parse(thisinfo):
if not thisinfo['Description']:
thisinfo['Description'].append('No description available')
for build in thisinfo['builds']:
fill_build_defaults(build)
thisinfo['builds'] = sorted(thisinfo['builds'], key=lambda build: int(build['vercode']))
# Parse metadata for a single application.
#
# 'metafile' - the filename to read. The package id for the application comes
@ -648,6 +659,8 @@ def parse_json_metadata(metafile):
del build['versionName']
# TODO create schema using https://pypi.python.org/pypi/jsonschema
post_metadata_parse(thisinfo)
return (appid, thisinfo)
@ -848,13 +861,7 @@ def parse_txt_metadata(metafile):
elif mode == 3:
raise MetaDataException("Unterminated build in " + metafile.name)
if not thisinfo['Description']:
thisinfo['Description'].append('No description available')
for build in thisinfo['builds']:
fill_build_defaults(build)
thisinfo['builds'] = sorted(thisinfo['builds'], key=lambda build: int(build['vercode']))
post_metadata_parse(thisinfo)
return (appid, thisinfo)