| Index: translations.py |
| =================================================================== |
| --- a/translations.py |
| +++ b/translations.py |
| @@ -1,16 +1,18 @@ |
| #!/usr/bin/env python |
| import filecmp |
| import os |
| import re |
| import shutil |
| import sys |
| import urllib2 |
| +if os.name == 'nt': |
| + import win32api, win32con |
| from lxml import etree |
| from StringIO import StringIO |
| from zipfile import ZipFile |
| import buildtools.localeTools |
| BASE_PATH = os.path.dirname(os.path.abspath(__file__)) |
| LOCALES_PATH = os.path.join(BASE_PATH, "mobile", "android", "base", "locales", |
| @@ -76,19 +78,34 @@ def get_progress_for_translation_diction |
| return languages |
| def remove_redundant_translations(): |
| default_locale_path = os.path.join(LOCALES_PATH, DEFAULT_LOCALE) |
| for locale in os.listdir(LOCALES_PATH): |
| if locale == DEFAULT_LOCALE: |
| continue |
| locale_path = os.path.join(LOCALES_PATH, locale) |
| + # ignore system files |
|
diegocarloslima
2017/09/19 20:03:54
I think you can change the comment to just 'ignore
jens
2017/09/20 08:38:12
Acknowledged.
|
| + if os.path.isfile(locale_path): |
| + continue; |
| + # ignore hidden folders |
| + if folder_is_hidden(locale_path): |
| + continue; |
| if not filecmp.dircmp(locale_path, default_locale_path).diff_files: |
| shutil.rmtree(locale_path) |
| +def folder_is_hidden(p): |
| + if os.name == 'nt': |
| + # windows |
| + attribute = win32api.GetFileAttributes(p) |
| + return attribute & (win32con.FILE_ATTRIBUTE_HIDDEN | win32con.FILE_ATTRIBUTE_SYSTEM) |
|
Vasily Kuznetsov
2017/09/19 21:48:04
Our Python style guide limits lines to 79 characte
jens
2017/09/20 08:38:12
Acknowledged.
|
| + else: |
| + # linux and osx |
| + return p.startswith('.') |
| + |
| if __name__ == "__main__": |
| if len(sys.argv) < 3: |
| print_usage() |
| sys.exit(1) |
| command, api_key = sys.argv[1:] |
| if command != "get": |
| print_usage() |