| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 | 2 |
| 3 import filecmp | 3 import filecmp |
| 4 import os | 4 import os |
| 5 import re | 5 import re |
| 6 import shutil | 6 import shutil |
| 7 import sys | 7 import sys |
| 8 import urllib2 | 8 import urllib2 |
| 9 from lxml import etree | 9 from lxml import etree |
| 10 from StringIO import StringIO | 10 from StringIO import StringIO |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 language.findtext('code'): language.findtext('translated_progress') | 74 language.findtext('code'): language.findtext('translated_progress') |
| 75 }) | 75 }) |
| 76 return languages | 76 return languages |
| 77 | 77 |
| 78 def remove_redundant_translations(): | 78 def remove_redundant_translations(): |
| 79 default_locale_path = os.path.join(LOCALES_PATH, DEFAULT_LOCALE) | 79 default_locale_path = os.path.join(LOCALES_PATH, DEFAULT_LOCALE) |
| 80 for locale in os.listdir(LOCALES_PATH): | 80 for locale in os.listdir(LOCALES_PATH): |
| 81 if locale == DEFAULT_LOCALE: | 81 if locale == DEFAULT_LOCALE: |
| 82 continue | 82 continue |
| 83 locale_path = os.path.join(LOCALES_PATH, locale) | 83 locale_path = os.path.join(LOCALES_PATH, locale) |
| 84 # ignore files |
| 85 if os.path.isfile(locale_path): |
| 86 continue |
| 87 # ignore hidden folders |
| 88 if locale_path.startswith('.'): |
| 89 continue |
| 84 if not filecmp.dircmp(locale_path, default_locale_path).diff_files: | 90 if not filecmp.dircmp(locale_path, default_locale_path).diff_files: |
| 85 shutil.rmtree(locale_path) | 91 shutil.rmtree(locale_path) |
| 86 | 92 |
| 87 if __name__ == "__main__": | 93 if __name__ == "__main__": |
| 88 if len(sys.argv) < 3: | 94 if len(sys.argv) < 3: |
| 89 print_usage() | 95 print_usage() |
| 90 sys.exit(1) | 96 sys.exit(1) |
| 91 | 97 |
| 92 command, api_key = sys.argv[1:] | 98 command, api_key = sys.argv[1:] |
| 93 if command != "get": | 99 if command != "get": |
| 94 print_usage() | 100 print_usage() |
| 95 sys.exit(2) | 101 sys.exit(2) |
| 96 | 102 |
| 97 get_translations(api_key) | 103 get_translations(api_key) |
| 98 remove_redundant_translations() | 104 remove_redundant_translations() |
| OLD | NEW |