1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-14 08:17:13 +03:00

l10n: Close localisation files after reading content

* These are opened in self.file() using codecs.open(), so no quick way
  to convert to a 'with'.
This commit is contained in:
Athanasius 2020-10-16 15:48:56 +01:00
parent 114379c8ed
commit f2ce63bfe7

View File

@ -131,6 +131,7 @@ class _Translations:
"""Load all the translations from a translation file."""
assert lang in self.available()
translations = {}
h = self.file(lang, plugin_path)
if not h:
return {}
@ -144,6 +145,7 @@ class _Translations:
elif not _Translations.COMMENT_RE.match(line):
logger.debug(f'Bad translation: {line.strip()}')
h.close()
if translations.get(LANGUAGE_ID, LANGUAGE_ID) == LANGUAGE_ID:
translations[LANGUAGE_ID] = str(lang) # Replace language name with code if missing