Index: mozharness/mozilla/l10n/locales.py |
=================================================================== |
--- a/mozharness/mozilla/l10n/locales.py |
+++ b/mozharness/mozilla/l10n/locales.py |
@@ -9,16 +9,18 @@ |
import os |
from urlparse import urljoin |
import sys |
from copy import deepcopy |
sys.path.insert(1, os.path.dirname(sys.path[0])) |
+# Added import. See https://issues.adblockplus.org/ticket/5579 |
+from mozharness.base.config import download_config_file |
from mozharness.base.config import parse_config_file |
from mozharness.base.errors import PythonErrorList |
from mozharness.base.parallel import ChunkingMixin |
# LocalesMixin {{{1 |
class LocalesMixin(ChunkingMixin): |
def __init__(self, **kwargs): |
@@ -40,16 +42,25 @@ class LocalesMixin(ChunkingMixin): |
if locales is None: |
locales = [] |
if 'locales_file' in c: |
# Best way to get abs/relative path to this? |
locales_file = os.path.join(c['base_work_dir'], c['work_dir'], |
c['locales_file']) |
locales = self.parse_locales_file(locales_file) |
+ # Added locales_json_url configuration |
+ # See https://issues.adblockplus.org/ticket/5579 |
+ elif 'locales_json_url' in c: |
+ locales_json_file = os.path.join(c['base_work_dir'], |
+ c['work_dir'], |
+ "generated", |
+ "locales.json") |
+ download_config_file(c['locales_json_url'], locales_json_file) |
+ locales = self.parse_locales_json(locales_json_file) |
else: |
self.fatal("No way to determine locales!") |
for locale in ignore_locales: |
if locale in locales: |
self.debug("Ignoring locale %s." % locale) |
locales.remove(locale) |
for locale in additional_locales: |
if locale not in locales: |
@@ -88,16 +99,28 @@ class LocalesMixin(ChunkingMixin): |
else: |
# some other way of getting this? |
self.locale_dict[locale] = 'default' |
locales.append(locale) |
else: |
locales = self.read_from_file(locales_file).split() |
return locales |
+ # Parses the appropriate revision/changeset for each locale |
+ # See https://issues.adblockplus.org/ticket/5579 |
+ def parse_locales_json(self, locales_json_file): |
+ locales = [] |
+ locales_json = parse_config_file(locales_json_file) |
+ self.locale_dict = {} |
+ locales_dict = locales_json['locales'] |
+ for locale in locales_dict.keys(): |
+ self.locale_dict[locale] = locales_dict[locale]['changeset'] |
+ locales.append(locale) |
+ return locales |
+ |
def run_compare_locales(self, locale, halt_on_failure=False): |
dirs = self.query_abs_dirs() |
compare_locales_script = os.path.join(dirs['abs_compare_locales_dir'], |
'scripts', 'compare-locales') |
env = self.query_env(partial_env={'PYTHONPATH': |
os.path.join(dirs['abs_compare_locales_dir'], |
'lib')}) |
compare_locales_error_list = list(PythonErrorList) |