use constants for names used in the config dict

Hopefully this helps with the Anti-Features case confusion:
* antifeatures
* antiFeatures
* AntiFeatures
This commit is contained in:
Hans-Christoph Steiner 2023-05-31 23:08:07 +02:00 committed by Michael Pöhn
parent 190a95ab17
commit 4e28fad55a
5 changed files with 34 additions and 16 deletions

View file

@ -112,6 +112,18 @@ XMLNS_ANDROID = '{http://schemas.android.com/apk/res/android}'
# https://docs.gitlab.com/ee/user/gitlab_com/#gitlab-pages
GITLAB_COM_PAGES_MAX_SIZE = 1000000000
# the names used for things that are configured per-repo
ANTIFEATURES_CONFIG_NAME = 'antiFeatures'
CATEGORIES_CONFIG_NAME = 'categories'
CONFIG_CONFIG_NAME = 'config'
RELEASECHANNELS_CONFIG_NAME = "releaseChannels"
CONFIG_NAMES = (
ANTIFEATURES_CONFIG_NAME,
CATEGORIES_CONFIG_NAME,
CONFIG_CONFIG_NAME,
RELEASECHANNELS_CONFIG_NAME,
)
config = None
options = None

View file

@ -42,7 +42,7 @@ from . import common
from . import metadata
from . import net
from . import signindex
from fdroidserver.common import DEFAULT_LOCALE, FDroidPopen, FDroidPopenBytes, load_stats_fdroid_signing_key_fingerprints
from fdroidserver.common import ANTIFEATURES_CONFIG_NAME, CATEGORIES_CONFIG_NAME, CONFIG_CONFIG_NAME, RELEASECHANNELS_CONFIG_NAME, DEFAULT_LOCALE, FDroidPopen, FDroidPopenBytes, load_stats_fdroid_signing_key_fingerprints
from fdroidserver.exception import FDroidException, VerificationException
@ -637,7 +637,7 @@ def convert_version(version, app, repodir):
if "versionCode" in version:
if version["versionCode"] > app["CurrentVersionCode"]:
ver["releaseChannels"] = ["Beta"]
ver[RELEASECHANNELS_CONFIG_NAME] = ["Beta"]
for build in app.get('Builds', []):
if build['versionCode'] == version['versionCode'] and "whatsNew" in build:
@ -656,7 +656,7 @@ def v2_repo(repodict, repodir, archive):
DEFAULT_LOCALE: common.file_entry("%s/icons/%s" % (repodir, repodict["icon"]))
}
config = common.load_localized_config("config", repodir)
config = common.load_localized_config(CONFIG_CONFIG_NAME, repodir)
if config:
repo["name"] = config["archive" if archive else "repo"]["name"]
repo["description"] = config["archive" if archive else "repo"]["description"]
@ -670,17 +670,17 @@ def v2_repo(repodict, repodir, archive):
repo["timestamp"] = repodict["timestamp"]
antiFeatures = common.load_localized_config("antiFeatures", repodir)
antiFeatures = common.load_localized_config(ANTIFEATURES_CONFIG_NAME, repodir)
if antiFeatures:
repo["antiFeatures"] = antiFeatures
repo[ANTIFEATURES_CONFIG_NAME] = antiFeatures
categories = common.load_localized_config("categories", repodir)
categories = common.load_localized_config(CATEGORIES_CONFIG_NAME, repodir)
if categories:
repo["categories"] = categories
repo[CATEGORIES_CONFIG_NAME] = categories
releaseChannels = common.load_localized_config("releaseChannels", repodir)
releaseChannels = common.load_localized_config(RELEASECHANNELS_CONFIG_NAME, repodir)
if releaseChannels:
repo["releaseChannels"] = releaseChannels
repo[RELEASECHANNELS_CONFIG_NAME] = releaseChannels
return repo

View file

@ -228,7 +228,7 @@ CATEGORIES_KEYS = list()
def load_antiFeatures_config():
"""Lazy loading, since it might read a lot of files."""
global ANTIFEATURES_KEYS, ANTIFEATURES_PATTERN
k = 'antiFeatures' # internal dict uses camelCase key name
k = common.ANTIFEATURES_CONFIG_NAME
if not ANTIFEATURES_KEYS or k not in common.config:
common.config[k] = common.load_localized_config(k, 'repo')
ANTIFEATURES_KEYS = sorted(common.config[k].keys())
@ -238,7 +238,7 @@ def load_antiFeatures_config():
def load_categories_config():
"""Lazy loading, since it might read a lot of files."""
global CATEGORIES_KEYS
k = 'categories'
k = common.CATEGORIES_CONFIG_NAME
if not CATEGORIES_KEYS:
if config and k in config:
CATEGORIES_KEYS = config[k]