From 790b5a2888444e9f69c9dba8b724f18c40c81980 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Thu, 1 Oct 2020 10:04:30 +0200 Subject: [PATCH] update: use "app" as dict not App instance in apply_info_from_latest_apk This allows update.apply_info_from_latest_apk() to be used as part of the API. This way "app" can be a dict or an App instance. --- fdroidserver/index.py | 2 +- fdroidserver/update.py | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/fdroidserver/index.py b/fdroidserver/index.py index d89e5cb8..078b64fb 100644 --- a/fdroidserver/index.py +++ b/fdroidserver/index.py @@ -61,7 +61,7 @@ def make(apps, apks, repodir, archive): common.assert_config_keystore(common.config) # Historically the index has been sorted by App Name, so we enforce this ordering here - sortedids = sorted(apps, key=lambda appid: apps[appid].Name.upper()) + sortedids = sorted(apps, key=lambda appid: apps[appid]['Name'].upper()) sortedapps = collections.OrderedDict() for appid in sortedids: sortedapps[appid] = apps[appid] diff --git a/fdroidserver/update.py b/fdroidserver/update.py index 0849442b..3f2903d1 100644 --- a/fdroidserver/update.py +++ b/fdroidserver/update.py @@ -1971,26 +1971,26 @@ def apply_info_from_latest_apk(apps, apks): bestver = apk['versionCode'] bestapk = apk - if app.NoSourceSince: + if app['NoSourceSince']: apk['antiFeatures'].add('NoSourceSince') - if not app.added: + if not app['added']: logging.debug("Don't know when " + appid + " was added") - if not app.lastUpdated: + if not app['lastUpdated']: logging.debug("Don't know when " + appid + " was last updated") if bestver == UNSET_VERSION_CODE: - if app.Name is None: - app.Name = app.AutoName or appid - app.icon = None + if app['Name'] is None: + app['Name'] = app['AutoName'] or appid + app['icon'] = None logging.debug("Application " + appid + " has no packages") else: - if app.Name is None: - app.Name = bestapk['name'] - app.icon = bestapk['icon'] if 'icon' in bestapk else None - if app.CurrentVersionCode is None: - app.CurrentVersionCode = str(bestver) + if app['Name'] is None: + app['Name'] = bestapk['name'] + app['icon'] = bestapk['icon'] if 'icon' in bestapk else None + if app['CurrentVersionCode'] is None: + app['CurrentVersionCode'] = str(bestver) def make_categories_txt(repodir, categories):