Bug 1468273 - Fix flake8/pep8 in intl/
MozReview-Commit-ID: IDqjd7nBRS
--- a/intl/icu_sources_data.py
+++ b/intl/icu_sources_data.py
@@ -79,21 +79,21 @@ def update_sources(topsrcdir):
for s in list_headers(mozpath.join(base_path, 'unicode'))]
write_sources(mozbuild, sources, headers)
def try_run(name, command, cwd=None, **kwargs):
try:
with tempfile.NamedTemporaryFile(prefix=name, delete=False) as f:
subprocess.check_call(command, cwd=cwd, stdout=f,
- stderr=subprocess.STDOUT, **kwargs)
+ stderr=subprocess.STDOUT, **kwargs)
except subprocess.CalledProcessError:
print('''Error running "{}" in directory {}
See output in {}'''.format(' '.join(command), cwd, f.name),
- file=sys.stderr)
+ file=sys.stderr)
return False
else:
os.unlink(f.name)
return True
def get_data_file(data_dir):
files = glob.glob(mozpath.join(data_dir, 'icudt*.dat'))
@@ -146,17 +146,17 @@ def update_data_file(topsrcdir):
print('Error: no ICU data in ICU objdir', file=sys.stderr)
return False
if os.path.basename(old_data_file) != os.path.basename(new_data_file):
# Data file name has the major version number embedded.
os.unlink(old_data_file)
shutil.copy(new_data_file, tree_data_path)
try:
shutil.rmtree(objdir)
- except:
+ except Exception:
print('Warning: failed to remove %s' % objdir, file=sys.stderr)
return True
def main():
if len(sys.argv) != 2:
print('Usage: icu_sources_data.py <mozilla topsrcdir>',
file=sys.stderr)
--- a/intl/locale/props2arrays.py
+++ b/intl/locale/props2arrays.py
@@ -1,27 +1,25 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-import sys
def main(header, propFile):
- mappings = {}
+ mappings = {}
+
+ with open(propFile, 'r') as f:
+ for line in f:
+ line = line.strip()
+ if not line.startswith('#'):
+ parts = line.split("=", 1)
+ if len(parts) == 2 and len(parts[0]) > 0:
+ mappings[parts[0].strip()] = parts[1].strip()
- with open(propFile, 'r') as f:
- for line in f:
- line = line.strip()
- if not line.startswith('#'):
- parts = line.split("=", 1)
- if len(parts) == 2 and len(parts[0]) > 0:
- mappings[parts[0].strip()] = parts[1].strip()
-
- keys = mappings.keys()
- keys.sort()
+ keys = mappings.keys()
+ keys.sort()
- header.write("// This is a generated file. Please do not edit.\n")
- header.write("// Please edit the corresponding .properties file instead.\n")
+ header.write("// This is a generated file. Please do not edit.\n")
+ header.write("// Please edit the corresponding .properties file instead.\n")
- entries = ['{ "%s", "%s", %d }'
- % (key, mappings[key], len(mappings[key])) for key in keys]
- header.write(',\n'.join(entries) + '\n')
-
+ entries = ['{ "%s", "%s", %d }'
+ % (key, mappings[key], len(mappings[key])) for key in keys]
+ header.write(',\n'.join(entries) + '\n')