chiark / gitweb /
move metadata post-parse processing to reusable function
authorHans-Christoph Steiner <hans@eds.org>
Wed, 22 Jul 2015 08:12:21 +0000 (01:12 -0700)
committerHans-Christoph Steiner <hans@eds.org>
Tue, 1 Sep 2015 09:39:50 +0000 (11:39 +0200)
fdroidserver/metadata.py

index c9a39dc75604aeca59b26a3fb1cef6e17f0f99d7..ac12599ddd832326cd3dbde4121a3af80ed8235b 100644 (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)