Browse Source

(hopefully) Improve readability of merge_translations step.

No functional changes intended.
wip/archive
Evilham 3 years ago
parent
commit
e23711cd8d
  1. 12
      amprolla_merge.py
  2. 14
      amprolla_merge_translations.py

12
amprolla_merge.py

@ -10,9 +10,9 @@ from multiprocessing import Pool
import sys
import lib.globalvars as globalvars
from lib.config import (aliases, arches, banpkgs, categories, cpunm, i18n, mergedir,
mergesubdir, pkgfiles, repos, repo_order, spooldir,
srcfiles, suites, skips)
from lib.config import (aliases, arches, banpkgs, categories, cpunm, i18n,
mergedir, mergesubdir, pkgfiles, repos, repo_order,
srcfiles, spooldir, suites, skips)
from lib.lock import run_with_amprolla_lock
from lib.package import (load_packages_file, merge_packages_many,
write_packages)
@ -140,8 +140,10 @@ def gen_release(suite):
if arch != 'source':
filelist.append(join(rootdir, cat,
'debian-installer', arch, i))
for i in i18n:
filelist.append(join(rootdir, cat, 'i18n', 'Translation-'+i+'.bz2'))
filelist.extend((join(rootdir, cat, 'i18n',
'Translation-{}.bz2'.format(lang))
for lang in i18n))
newrfl = join(rootdir, 'Release')
oldrfl = newrfl.replace(join(mergedir, mergesubdir),

14
amprolla_merge_translations.py

@ -32,16 +32,24 @@ def merge_translations(filelist):
Merges a list of Translation files and returns a dict of the merged files
"""
merged_trnsl = {}
for f in filelist[::-1]: # Slice list in reverse repo_order so Devuan is merged last.
if not filelist:
return merged_trnsl
# This is determined in lib.config.repo_order
devuan_translation = filelist[0]
for f in reversed(filelist):
# Iteration order matters because we use .update on the dictionary.
# We use reverse lib.config.repo_order so Devuan is merged last and
# therefore has priority.
if f is None:
continue
elif isfile(f):
trnsl = parse_translations_file(f)
merged_trnsl.update(trnsl)
elif merged_trnsl and f == filelist[0]:
elif merged_trnsl and f == devuan_translation:
# In the absence of Devuan translations for forked packages, just
# remove upstream ones in case they are incorrect.
trnsl = parse_translations_file(join(dirname(f),'Translation-en.bz2'))
trnsl = parse_translations_file(join(dirname(f),
'Translation-en.bz2'))
print("%s not found: removing upstream translations of forked packages" % f)
for k in trnsl.keys():
merged_trnsl.pop(k, None)

Loading…
Cancel
Save