mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-10-09 02:41:06 +03:00
Make app['Categories'] a list, get unique categories via a set
This commit is contained in:
parent
be7c6aceec
commit
3483bad392
3 changed files with 10 additions and 13 deletions
|
@ -440,6 +440,8 @@ def read_metadata(xref=True, package=None, store=True):
|
|||
def metafieldtype(name):
|
||||
if name in ['Description', 'Maintainer Notes']:
|
||||
return 'multiline'
|
||||
if name in ['Categories']:
|
||||
return 'list'
|
||||
if name == 'Build Version':
|
||||
return 'build'
|
||||
if name == 'Build':
|
||||
|
@ -629,6 +631,8 @@ def parse_metadata(metafile):
|
|||
raise MetaDataException("Unexpected text on same line as " + field + " in " + linedesc)
|
||||
elif fieldtype == 'string':
|
||||
thisinfo[field] = value
|
||||
elif fieldtype == 'list':
|
||||
thisinfo[field] = [v.strip() for v in value.replace(';',',').split(',')]
|
||||
elif fieldtype == 'build':
|
||||
if value.endswith("\\"):
|
||||
mode = 2
|
||||
|
|
|
@ -204,10 +204,7 @@ def main():
|
|||
logging.info("Processing categories...")
|
||||
ctgs = Counter()
|
||||
for app in metaapps:
|
||||
if app['Categories'] is None:
|
||||
continue
|
||||
categories = [c.strip() for c in app['Categories'].split(',')]
|
||||
for category in categories:
|
||||
for category in app['Categories']:
|
||||
ctgs[category] += 1;
|
||||
f = open('stats/categories.txt', 'w')
|
||||
for category in ctgs:
|
||||
|
|
|
@ -190,7 +190,7 @@ def update_wiki(apps, apks):
|
|||
wikidata += '\n[[Category:Apps that are disabled]]\n'
|
||||
if app['Update Check Mode'] == 'None' and not app['Disabled']:
|
||||
wikidata += '\n[[Category:Apps with no update check]]\n'
|
||||
for appcat in [c.strip() for c in app['Categories'].split(',')]:
|
||||
for appcat in app['Categories']:
|
||||
wikidata += '\n[[Category:{0}]]\n'.format(appcat)
|
||||
|
||||
# We can't have underscores in the page name, even if they're in
|
||||
|
@ -689,12 +689,11 @@ def make_index(apps, apks, repodir, archive, categories):
|
|||
metadata.description_html(app['Description'], linkres), doc, apel)
|
||||
addElement('license', app['License'], doc, apel)
|
||||
if 'Categories' in app:
|
||||
appcategories = [c.strip() for c in app['Categories'].split(',')]
|
||||
addElement('categories', ','.join(appcategories), doc, apel)
|
||||
addElement('categories', ','.join(app["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.
|
||||
addElement('category', appcategories[0], doc, apel)
|
||||
addElement('category', app["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)
|
||||
|
@ -895,12 +894,9 @@ def main():
|
|||
apps = metadata.read_metadata()
|
||||
|
||||
# Generate a list of categories...
|
||||
categories = []
|
||||
categories = set()
|
||||
for app in apps:
|
||||
cats = app['Categories'].split(',')
|
||||
for cat in cats:
|
||||
if cat not in categories:
|
||||
categories.append(cat)
|
||||
categories.update(app['Categories'])
|
||||
|
||||
# Read known apks data (will be updated and written back when we've finished)
|
||||
knownapks = common.KnownApks()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue