From 2b726341205c24fa6e2a17c38760be4747bdc10d Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Tue, 21 Jul 2015 11:46:01 -0700 Subject: [PATCH] use common method to set up defaults in metadata dict This is needed for the upcoming metadata formats: JSON, XML, etc. --- fdroidserver/metadata.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/fdroidserver/metadata.py b/fdroidserver/metadata.py index 587c4aab..83bdbc4e 100644 --- a/fdroidserver/metadata.py +++ b/fdroidserver/metadata.py @@ -560,6 +560,17 @@ def split_list_values(s): return [v for v in l if v] +def get_default_app_info_list(): + thisinfo = {} + thisinfo.update(app_defaults) + + # General defaults... + thisinfo['builds'] = [] + thisinfo['comments'] = [] + + return thisinfo + + # Parse metadata for a single application. # # 'metafile' - the filename to read. The package id for the application comes @@ -661,20 +672,13 @@ def parse_txt_metadata(metafile): thisinfo['comments'].append((key, comment)) del curcomments[:] - thisinfo = {} + thisinfo = get_default_app_info_list() if metafile: if not isinstance(metafile, file): metafile = open(metafile, "r") appid = metafile.name[9:-4] - - thisinfo.update(app_defaults) - thisinfo['id'] = appid - - # General defaults... - thisinfo['builds'] = [] - thisinfo['comments'] = [] - - if metafile is None: + thisinfo['id'] = appid + else: return appid, thisinfo mode = 0 -- 2.30.2