From ee759a3a0e4b8b52750769e4477c509b8dcdd1be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Sat, 2 Nov 2013 01:14:01 +0100 Subject: [PATCH] Start doing multiple categories as comma separated lists Don't drop support for old clients (only one category) yet --- fdroidserver/common.py | 4 ++-- fdroidserver/stats.py | 4 ++-- fdroidserver/update.py | 9 ++++----- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/fdroidserver/common.py b/fdroidserver/common.py index c1e49470..947df11f 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -551,7 +551,7 @@ def parse_metadata(metafile, verbose=False): # Defaults for fields that come from metadata... thisinfo['Name'] = None thisinfo['Auto Name'] = '' - thisinfo['Category'] = 'None' + thisinfo['Categories'] = 'None' thisinfo['Description'] = [] thisinfo['Summary'] = '' thisinfo['License'] = 'Unknown' @@ -761,7 +761,7 @@ def write_metadata(dest, app, verbose=False): writefield('Disabled') if app['AntiFeatures']: writefield('AntiFeatures') - writefield('Category') + writefield('Categories') writefield('License') writefield('Web Site') writefield('Source Code') diff --git a/fdroidserver/stats.py b/fdroidserver/stats.py index ad5b82c0..f84af85a 100644 --- a/fdroidserver/stats.py +++ b/fdroidserver/stats.py @@ -182,9 +182,9 @@ def main(): ctgs = {} for app in metaapps: - if app['Category'] is None: + if app['Categories'] is None: continue - categories = [c.strip() for c in app['Category'].split(';')] + categories = [c.strip() for c in app['Categories'].split(',')] for category in categories: if category in ctgs: ctgs[category] += 1; diff --git a/fdroidserver/update.py b/fdroidserver/update.py index 16fe6008..85a75def 100644 --- a/fdroidserver/update.py +++ b/fdroidserver/update.py @@ -527,14 +527,13 @@ def make_index(apps, apks, repodir, archive, categories): addElement('desc', common.description_html(app['Description'], linkres), doc, apel) addElement('license', app['License'], doc, apel) - if 'Category' in app: + if 'Categories' in app: + categories = [c.strip() for c in app['Categories'].split(',')] + addElement('categories', ','.join(categories), doc, apel) # We put the first (primary) category in LAST, which will have # the desired effect of making clients that only understand one # category see that one. - cats = app['Category'].split(';') - cats.reverse() - for cat in cats: - addElement('category', cat, doc, apel) + addElement('category', categories[0], doc, apel) addElement('web', app['Web Site'], doc, apel) addElement('source', app['Source Code'], doc, apel) addElement('tracker', app['Issue Tracker'], doc, apel)