From 3aedca7bd6621d5ce38000c55379825ab7dde169 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Sun, 23 Feb 2014 13:50:54 +0100 Subject: [PATCH] Always read line-by-line with mode rU --- bin/combine-examples.py | 2 +- bin/generate-exports.py | 2 +- bin/pyglslunit.py | 2 +- build.py | 14 +++++++------- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/bin/combine-examples.py b/bin/combine-examples.py index 67c02ab2dd..7a71fac2c5 100755 --- a/bin/combine-examples.py +++ b/bin/combine-examples.py @@ -8,7 +8,7 @@ def main(argv): examples = {} requires = set() for filename in argv[1:]: - lines = open(filename).readlines() + lines = open(filename, 'rU').readlines() if len(lines) > 0 and lines[0].startswith('// NOCOMPILE'): continue requires.update(line for line in lines if line.startswith('goog.require')) diff --git a/bin/generate-exports.py b/bin/generate-exports.py index 3e864df72a..562f99aa92 100755 --- a/bin/generate-exports.py +++ b/bin/generate-exports.py @@ -113,7 +113,7 @@ def main(argv): for arg in args: in_comment = False object_literal = None - for line in open(arg): + for line in open(arg, 'rU'): line = line.strip() if not line: continue diff --git a/bin/pyglslunit.py b/bin/pyglslunit.py index 47be9c7fdc..0a7f55627c 100644 --- a/bin/pyglslunit.py +++ b/bin/pyglslunit.py @@ -52,7 +52,7 @@ def main(argv): common, vertex, fragment = [], [], [] attributes, uniforms, varyings = {}, {}, {} block = None - for line in open(options.input): + for line in open(options.input, 'rU'): if line.startswith('//!'): m = re.match(r'//!\s+NAMESPACE=(\S+)\s*\Z', line) if m: diff --git a/build.py b/build.py index 741389d301..635d33da89 100755 --- a/build.py +++ b/build.py @@ -251,7 +251,7 @@ for glsl_src in GLSL_SRC: def _build_require_list(dependencies, output_file_name): requires = set() for dependency in dependencies: - for line in open(dependency): + for line in open(dependency, 'rU'): match = re.match(r'goog\.provide\(\'(.*)\'\);', line) if match: requires.add(match.group(1)) @@ -449,7 +449,7 @@ def build_check_requires_timestamp(t): # the generated regular expression to exceed Python's limits if zi.filename.startswith('closure/goog/i18n/'): continue - for line in zf.open(zi): + for line in zf.open(zi, 'rU'): m = re.match(r'goog.provide\(\'(.*)\'\);', line) if m: all_provides.add(m.group(1)) @@ -458,7 +458,7 @@ def build_check_requires_timestamp(t): continue require_linenos = {} uses = set() - lines = open(filename).readlines() + lines = open(filename, 'rU').readlines() for lineno, line in _strip_comments(lines): m = re.match(r'goog.provide\(\'(.*)\'\);', line) if m: @@ -541,7 +541,7 @@ def build_check_requires_timestamp(t): requires = set() uses = set() uses_linenos = {} - for lineno, line in _strip_comments(open(filename)): + for lineno, line in _strip_comments(open(filename, 'rU')): m = re.match(r'goog.provide\(\'(.*)\'\);', line) if m: provides.add(m.group(1)) @@ -590,7 +590,7 @@ def build_check_whitespace_timestamp(t): errors = 0 for filename in sorted(t.newer(t.dependencies)): whitespace = False - for lineno, line in enumerate(open(filename)): + for lineno, line in enumerate(open(filename, 'rU')): if CR_RE.search(line): t.info('%s:%d: carriage return character in line', filename, lineno + 1) errors += 1 @@ -633,7 +633,7 @@ def jsdoc_BRANCH_timestamp(t): def split_example_file(example, dst_dir): - lines = open(example).readlines() + lines = open(example, 'rU').readlines() target_lines = [] target_require_lines = [] @@ -709,7 +709,7 @@ def host_examples(t): def check_examples(t): examples = ['build/hosted/%(BRANCH)s/' + e for e in EXAMPLES - if not open(e.replace('.html', '.js')).readline().startswith('// NOCOMPILE')] + if not open(e.replace('.html', '.js'), 'rU').readline().startswith('// NOCOMPILE')] all_examples = \ [e + '?mode=advanced' for e in examples] for example in all_examples: