Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
PACKAGE_HOME = os.path.join(PACKAGE_HOME, '..')
i18ndir = os.path.normpath(PACKAGE_HOME)
tests=[]
products=[]
pots={}
pot_catalogs={}
pot_lens={}
for potFile in getPotFiles(path=i18ndir):
product = getProductFromPath(potFile)
if product not in products:
products.append(product)
if product not in pot_catalogs:
cat = catalog.MessageCatalog(filename=potFile)
cat_len = len(cat)
pots.update({product: potFile})
pot_catalogs.update({product: cat})
pot_lens.update({product: cat_len})
for product in products:
class TestOnePOT(PotTestCase.PotTestCase):
product = product
pot = pots[product]
tests.append(TestOnePOT)
for poFile in getPoFiles(path=i18ndir, product=product):
class TestOnePoFile(PoTestCase.PoTestCase):
po = poFile
product = product
pot_cat = pot_catalogs[product]
# make sure we only try on languages for which both po files exist
ploneLanguages = [getLanguage('plone', p) for p in poFilesPlone]
atctLanguages = [getLanguage('atcontenttypes', p) for p in poFilesATCT]
languages = [l for l in ploneLanguages if l in atctLanguages and l != 'en']
changes = {'plone' : False, 'atcontenttypes' : False}
for lang in languages:
po_ctl = {}
try:
po_ctl['plone'] = catalog.MessageCatalog(filename='plone-%s.po' % lang)
except IOError as e:
print('I/O Error: %s' % e, file=sys.stderr)
try:
po_ctl['atcontenttypes'] = catalog.MessageCatalog(filename='atcontenttypes-%s.po' % lang)
except IOError as e:
print('I/O Error: %s' % e, file=sys.stderr)
changes = {'plone' : False, 'atcontenttypes' : False}
relocate_domain = {'plone' : 'atcontenttypes', 'atcontenttypes' : 'plone'}
msgids = {}
msgids['plone'] = list(po_ctl['plone'].keys())
msgids['atcontenttypes'] = list(po_ctl['atcontenttypes'].keys())
for old_domain in relocated:
relocate_msgids = relocated.get(old_domain)
for relocate_msgid in relocate_msgids:
if relocate_msgid in msgids[old_domain]:
msgstr = po_ctl[old_domain].get(relocate_msgid)