Merge pull request #1749 from twpayne/windows-newlines

Generate proper line endings on Windows
This commit is contained in:
Tom Payne
2014-02-25 22:26:54 +01:00
5 changed files with 155 additions and 32 deletions

View File

@@ -8,19 +8,19 @@ 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'))
examples[filename] = [line for line in lines if not line.startswith('goog.require')]
for require in sorted(requires):
print require,
sys.stdout.write(require)
for filename in sorted(examples.keys()):
print '// ', filename
print '(function(){'
sys.stdout.write('// ' + filename + '\n')
sys.stdout.write('(function(){\n')
for line in examples[filename]:
print line,
print '})();'
sys.stdout.write(line)
sys.stdout.write('})();\n')
if __name__ == '__main__':

View File

@@ -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

View File

@@ -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:
@@ -111,10 +111,10 @@ def main(argv):
context['getUniforms'] = [uniforms[u] for u in sorted(uniforms.keys())]
if options.output and options.output != '-':
output = open(options.output, 'w')
output = open(options.output, 'wb')
else:
output = sys.stdout
output.write(pystache.render(open(options.template).read(), context))
output.write(pystache.render(open(options.template, 'rb').read(), context))
if __name__ == '__main__':