From: Hans-Christoph Steiner Date: Tue, 21 Jul 2015 18:46:01 +0000 (-0700) Subject: use common method to set up defaults in metadata dict X-Git-Tag: 0.5.0~140^2~20 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=2b726341205c24fa6e2a17c38760be4747bdc10d;p=fdroidserver.git use common method to set up defaults in metadata dict This is needed for the upcoming metadata formats: JSON, XML, etc. --- 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