mirror of
https://github.com/f-droid/fdroidserver.git
synced 2026-05-24 08:44:54 -04:00
fix "doesn't conform to UPPER_CASE naming style (invalid-name)"
This commit is contained in:
committed by
Michael Pöhn
parent
359587b4ae
commit
778b6527a0
@@ -12,16 +12,16 @@ rootpaths = [
|
||||
os.path.join(sys.prefix, 'share'),
|
||||
]
|
||||
|
||||
localedir = None
|
||||
LOCALEDIR = None
|
||||
for rootpath in rootpaths:
|
||||
found_mo = glob.glob(
|
||||
os.path.join(rootpath, 'locale', '*', 'LC_MESSAGES', 'fdroidserver.mo')
|
||||
)
|
||||
if len(found_mo) > 0:
|
||||
localedir = os.path.join(rootpath, 'locale')
|
||||
LOCALEDIR = os.path.join(rootpath, 'locale')
|
||||
break
|
||||
|
||||
gettext.bindtextdomain('fdroidserver', localedir)
|
||||
gettext.bindtextdomain('fdroidserver', LOCALEDIR)
|
||||
gettext.textdomain('fdroidserver')
|
||||
_ = gettext.gettext
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ APK_SDK_VERSION_PAT = re.compile(".*'([0-9]*)'.*")
|
||||
APK_PERMISSION_PAT = re.compile(r".*name='([^']*)'(?:.*maxSdkVersion='([^']*)')?.*")
|
||||
APK_FEATURE_PAT = re.compile(".*name='([^']*)'.*")
|
||||
|
||||
screen_densities = [65534, 640, 480, 320, 240, 160, 120]
|
||||
SCREEN_DENSITIES = [65534, 640, 480, 320, 240, 160, 120]
|
||||
# resolutions must end with 'dpi'
|
||||
# https://android.googlesource.com/platform/tools/base/+/refs/tags/studio-2025.3.4/build-system/aaptcompiler/src/main/java/com/android/aaptcompiler/android/ResTableConfig.kt#372
|
||||
screen_resolutions = {
|
||||
@@ -182,7 +182,7 @@ def get_icon_dir(repodir, density):
|
||||
|
||||
|
||||
def get_icon_dirs(repodir):
|
||||
for density in screen_densities:
|
||||
for density in SCREEN_DENSITIES:
|
||||
yield get_icon_dir(repodir, density)
|
||||
|
||||
|
||||
@@ -342,7 +342,7 @@ def resize_all_icons(repodirs):
|
||||
the repo directories to process
|
||||
"""
|
||||
for repodir in repodirs:
|
||||
for density in screen_densities:
|
||||
for density in SCREEN_DENSITIES:
|
||||
icon_dir = get_icon_dir(repodir, density)
|
||||
icon_glob = os.path.join(icon_dir, '*.png')
|
||||
for iconpath in glob.glob(icon_glob):
|
||||
@@ -2302,7 +2302,7 @@ def extract_apk_icons(icon_filename, apk, apkzip, repo_dir):
|
||||
|
||||
"""
|
||||
empty_densities = []
|
||||
for density in screen_densities:
|
||||
for density in SCREEN_DENSITIES:
|
||||
if density not in apk['icons_src']:
|
||||
empty_densities.append(density)
|
||||
continue
|
||||
@@ -2339,10 +2339,10 @@ def extract_apk_icons(icon_filename, apk, apkzip, repo_dir):
|
||||
try:
|
||||
im = Image.open(icon_path)
|
||||
dpi = px_to_dpi(im.size[0])
|
||||
for density in screen_densities:
|
||||
for density in SCREEN_DENSITIES:
|
||||
if density in apk['icons']:
|
||||
break
|
||||
if density == screen_densities[-1] or dpi >= density:
|
||||
if density == SCREEN_DENSITIES[-1] or dpi >= density:
|
||||
apk['icons'][density] = icon_filename
|
||||
shutil.move(icon_path,
|
||||
os.path.join(get_icon_dir(repo_dir, density), icon_filename))
|
||||
@@ -2374,7 +2374,7 @@ def fill_missing_icon_densities(empty_densities, icon_filename, apk, repo_dir):
|
||||
"""
|
||||
# First try resizing down to not lose quality
|
||||
last_density = None
|
||||
for density in screen_densities:
|
||||
for density in SCREEN_DENSITIES:
|
||||
if density == 65534: # not possible to generate 'anydpi' from other densities
|
||||
continue
|
||||
if density not in empty_densities:
|
||||
@@ -2405,7 +2405,7 @@ def fill_missing_icon_densities(empty_densities, icon_filename, apk, repo_dir):
|
||||
|
||||
# Then just copy from the highest resolution available
|
||||
last_density = None
|
||||
for density in reversed(screen_densities):
|
||||
for density in reversed(SCREEN_DENSITIES):
|
||||
if density not in empty_densities:
|
||||
last_density = density
|
||||
continue
|
||||
@@ -2420,7 +2420,7 @@ def fill_missing_icon_densities(empty_densities, icon_filename, apk, repo_dir):
|
||||
empty_densities.remove(density)
|
||||
|
||||
# If any of the icons are too big, then size them down.
|
||||
for density in screen_densities:
|
||||
for density in SCREEN_DENSITIES:
|
||||
icon_dir = get_icon_dir(repo_dir, density)
|
||||
icon_dest = os.path.join(icon_dir, icon_filename)
|
||||
resize_icon(icon_dest, density)
|
||||
@@ -2534,7 +2534,7 @@ def move_apk_between_sections(from_dir, to_dir, apk):
|
||||
_move_file(from_dir, to_dir, filename + '.asc', True)
|
||||
_move_file(from_dir, to_dir, filename + '.idsig', True)
|
||||
_move_file(from_dir, to_dir, filename[:-4] + '.log.gz', True)
|
||||
for density in screen_densities:
|
||||
for density in SCREEN_DENSITIES:
|
||||
from_icon_dir = get_icon_dir(from_dir, density)
|
||||
to_icon_dir = get_icon_dir(to_dir, density)
|
||||
default = get_old_icon_filename(apk['packageName'], apk['versionCode'])
|
||||
|
||||
@@ -1128,7 +1128,7 @@ class UpdateTest(SetUpTearDownMixin, unittest.TestCase):
|
||||
self.assertEqual(apk['icon'], 'info.guardianproject.urzip.100.png')
|
||||
if apkName == '../org.dyndns.fules.ck_20.apk':
|
||||
self.assertEqual(apk['icon'], 'org.dyndns.fules.ck.20.png')
|
||||
for density in fdroidserver.update.screen_densities:
|
||||
for density in fdroidserver.update.SCREEN_DENSITIES:
|
||||
icon_path = os.path.join(
|
||||
fdroidserver.update.get_icon_dir('repo', density), apk['icon']
|
||||
)
|
||||
@@ -1221,7 +1221,7 @@ class UpdateTest(SetUpTearDownMixin, unittest.TestCase):
|
||||
self.assertFalse(os.path.exists(os.path.join('repo', apkName)))
|
||||
|
||||
# ensure that icons have been moved to the archive as well
|
||||
for density in fdroidserver.update.screen_densities:
|
||||
for density in fdroidserver.update.SCREEN_DENSITIES:
|
||||
icon_path = os.path.join(fdroidserver.update.get_icon_dir('archive', density),
|
||||
apk['icon'])
|
||||
self.assertTrue(os.path.isfile(icon_path))
|
||||
@@ -2364,7 +2364,7 @@ class TestExtractApkIcons(SetUpTearDownMixin, unittest.TestCase):
|
||||
appid = 'SpeedoMeterApp.main'
|
||||
apkfile = basedir / f'{appid}_1.apk'
|
||||
empty_densities = self.extract_apk_icons(apkfile, appid)
|
||||
self.assertEqual(fdroidserver.update.screen_densities, empty_densities)
|
||||
self.assertEqual(fdroidserver.update.SCREEN_DENSITIES, empty_densities)
|
||||
self.assertFalse(os.path.exists(f'repo/icons/{self.filename}'))
|
||||
for density in empty_densities:
|
||||
self.assertFalse(os.path.exists(f'repo/icons-{density}/{self.filename}'))
|
||||
@@ -2374,7 +2374,7 @@ class TestExtractApkIcons(SetUpTearDownMixin, unittest.TestCase):
|
||||
appid = 'info.zwanenburg.caffeinetile'
|
||||
apkfile = basedir / f'repo/{appid}_4.apk'
|
||||
empty_densities = self.extract_apk_icons(apkfile, appid)
|
||||
self.assertEqual(fdroidserver.update.screen_densities, empty_densities)
|
||||
self.assertEqual(fdroidserver.update.SCREEN_DENSITIES, empty_densities)
|
||||
self.assertFalse(os.path.exists(f'repo/icons/{self.filename}'))
|
||||
for density in empty_densities:
|
||||
self.assertFalse(os.path.exists(f'repo/icons-{density}/{self.filename}'))
|
||||
|
||||
Reference in New Issue
Block a user