From ac004264f0916d391f339273db2a4f4908b31b27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Fri, 15 May 2015 16:51:58 +0200 Subject: [PATCH] Make comma-separated list parsing code common --- fdroidserver/common.py | 2 +- fdroidserver/metadata.py | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/fdroidserver/common.py b/fdroidserver/common.py index 985afb4a..a3275e43 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -1154,7 +1154,7 @@ def getsrclib(spec, srclib_dir, srclibpaths=[], subdir=None, if srclib["Srclibs"]: n = 1 - for lib in srclib["Srclibs"].replace(';', ',').split(','): + for lib in metadata.split_list_values(srclib["Srclibs"]): s_tuple = None for t in srclibpaths: if t[0] == lib: diff --git a/fdroidserver/metadata.py b/fdroidserver/metadata.py index 0bf9f602..fada0ead 100644 --- a/fdroidserver/metadata.py +++ b/fdroidserver/metadata.py @@ -552,6 +552,12 @@ def fill_build_defaults(build): build['ndk_path'] = common.get_ndk_path(build['ndk']) +def split_list_values(s): + # Port legacy ';' separators + l = [v.strip() for v in s.replace(';', ',').split(',')] + return [v for v in l if v] + + # Parse metadata for a single application. # # 'metafile' - the filename to read. The package id for the application comes @@ -597,8 +603,7 @@ def parse_metadata(metafile): .format(p, linedesc)) t = flagtype(pk) if t == 'list': - # Port legacy ';' separators - pv = [v.strip() for v in pv.replace(';', ',').split(',')] + pv = split_list_values(pv) if pk == 'gradle': if len(pv) == 1 and pv[0] in ['main', 'yes']: pv = ['yes'] @@ -727,7 +732,7 @@ def parse_metadata(metafile): elif fieldtype == 'string': thisinfo[field] = value elif fieldtype == 'list': - thisinfo[field] = [v.strip() for v in value.replace(';', ',').split(',')] + thisinfo[field] = split_list_values(value) elif fieldtype == 'build': if value.endswith("\\"): mode = 2