Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: translations.py

Issue 29549604: Issue 5729 - remove_redundant_translations fails due to the presence of system file (Closed)
Left Patch Set: Removed Windows part Created Sept. 20, 2017, 8:47 a.m.
Right Patch Set: removed simicolons Created Sept. 26, 2017, 12:09 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 84 # ignore files
85 if os.path.isfile(locale_path): 85 if os.path.isfile(locale_path):
86 continue; 86 continue
Vasily Kuznetsov 2017/09/22 16:27:10 You don't need the semicolon at the end of the lin
jens 2017/09/26 12:09:17 Ah, you're right. I know it's not necessary in pyt
87 # ignore hidden folders 87 # ignore hidden folders
88 if locale_path.startswith('.'): 88 if locale_path.startswith('.'):
89 continue; 89 continue
90 if not filecmp.dircmp(locale_path, default_locale_path).diff_files: 90 if not filecmp.dircmp(locale_path, default_locale_path).diff_files:
91 shutil.rmtree(locale_path) 91 shutil.rmtree(locale_path)
92 92
93 if __name__ == "__main__": 93 if __name__ == "__main__":
94 if len(sys.argv) < 3: 94 if len(sys.argv) < 3:
95 print_usage() 95 print_usage()
96 sys.exit(1) 96 sys.exit(1)
97 97
98 command, api_key = sys.argv[1:] 98 command, api_key = sys.argv[1:]
99 if command != "get": 99 if command != "get":
100 print_usage() 100 print_usage()
101 sys.exit(2) 101 sys.exit(2)
102 102
103 get_translations(api_key) 103 get_translations(api_key)
104 remove_redundant_translations() 104 remove_redundant_translations()
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld