| OLD | NEW | 
|    1 # This Source Code Form is subject to the terms of the Mozilla Public |    1 # This Source Code Form is subject to the terms of the Mozilla Public | 
|    2 # License, v. 2.0. If a copy of the MPL was not distributed with this |    2 # License, v. 2.0. If a copy of the MPL was not distributed with this | 
|    3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. |    3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. | 
|    4  |    4  | 
|    5 import re |    5 import re | 
|    6 import os |    6 import os | 
|    7 import sys |    7 import sys | 
|    8 import codecs |    8 import codecs | 
|    9 import json |    9 import json | 
|   10 import urlparse |   10 import urlparse | 
| (...skipping 23 matching lines...) Expand all  Loading... | 
|   34     'sv': 'sv-SE', |   34     'sv': 'sv-SE', | 
|   35     'ur': 'ur-PK', |   35     'ur': 'ur-PK', | 
|   36 } |   36 } | 
|   37  |   37  | 
|   38 CROWDIN_AP_URL = 'https://api.crowdin.com/api/project' |   38 CROWDIN_AP_URL = 'https://api.crowdin.com/api/project' | 
|   39 FIREFOX_RELEASES_URL = 'http://www.mozilla.org/en-US/firefox/all.html' |   39 FIREFOX_RELEASES_URL = 'http://www.mozilla.org/en-US/firefox/all.html' | 
|   40 FIREFOX_LP_URL = 'https://addons.mozilla.org/en-US/firefox/language-tools/' |   40 FIREFOX_LP_URL = 'https://addons.mozilla.org/en-US/firefox/language-tools/' | 
|   41 CHROMIUM_DEB_URL = 'https://packages.debian.org/sid/all/chromium-l10n/filelist' |   41 CHROMIUM_DEB_URL = 'https://packages.debian.org/sid/all/chromium-l10n/filelist' | 
|   42  |   42  | 
|   43  |   43  | 
 |   44 def read_locale_config(baseDir, platform, metadata): | 
 |   45     if platform != 'generic': | 
 |   46         import buildtools.packagerChrome as packager | 
 |   47         localeDir = os.path.join(baseDir, '_locales') | 
 |   48         localeConfig = { | 
 |   49             'default_locale': packager.defaultLocale, | 
 |   50         } | 
 |   51     else: | 
 |   52         localeDir = os.path.join( | 
 |   53             baseDir, *metadata.get('locales', 'base_path').split('/') | 
 |   54         ) | 
 |   55         localeConfig = { | 
 |   56             'default_locale': metadata.get('locales', 'default_locale') | 
 |   57         } | 
 |   58  | 
 |   59     localeConfig['base_path'] = localeDir | 
 |   60  | 
 |   61     locales = [(locale.replace('_', '-'), os.path.join(localeDir, locale)) | 
 |   62                for locale in os.listdir(localeDir)] | 
 |   63     localeConfig['locales'] = dict(locales) | 
 |   64  | 
 |   65     return localeConfig | 
 |   66  | 
 |   67  | 
|   44 def crowdin_request(project_name, action, key, get={}, post_data=None, |   68 def crowdin_request(project_name, action, key, get={}, post_data=None, | 
|   45                     headers={}, raw=False): |   69                     headers={}, raw=False): | 
|   46     """Perform a call to crowdin and raise an Exception on failure.""" |   70     """Perform a call to crowdin and raise an Exception on failure.""" | 
|   47     request = urllib2.Request( |   71     request = urllib2.Request( | 
|   48         '{}/{}/{}?{}'.format(CROWDIN_AP_URL, |   72         '{}/{}/{}?{}'.format(CROWDIN_AP_URL, | 
|   49                              urllib.quote(project_name), |   73                              urllib.quote(project_name), | 
|   50                              urllib.quote(action), |   74                              urllib.quote(action), | 
|   51                              urllib.urlencode(dict(get, key=key, json=1))), |   75                              urllib.urlencode(dict(get, key=key, json=1))), | 
|   52         post_data, |   76         post_data, | 
|   53         headers, |   77         headers, | 
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  294     # Remove any extra files |  318     # Remove any extra files | 
|  295     for dir, files in dirs.iteritems(): |  319     for dir, files in dirs.iteritems(): | 
|  296         baseDir = os.path.join(localeConfig['base_path'], dir) |  320         baseDir = os.path.join(localeConfig['base_path'], dir) | 
|  297         if not os.path.exists(baseDir): |  321         if not os.path.exists(baseDir): | 
|  298             continue |  322             continue | 
|  299         for file in os.listdir(baseDir): |  323         for file in os.listdir(baseDir): | 
|  300             path = os.path.join(baseDir, file) |  324             path = os.path.join(baseDir, file) | 
|  301             valid_extension = file.endswith('.json') |  325             valid_extension = file.endswith('.json') | 
|  302             if os.path.isfile(path) and valid_extension and not file in files: |  326             if os.path.isfile(path) and valid_extension and not file in files: | 
|  303                 os.remove(path) |  327                 os.remove(path) | 
| OLD | NEW |