Commit c948956b authored by Yoichi Osato's avatar Yoichi Osato Committed by Commit Bot

[fetch] Make generate.py write files in binary mode

This CL has it generate same result both on Linux and Windows
while avoiding line-end mismatch.

Change-Id: I99636aa42f5e386208f92dcfe9b0480ebd803caf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2033061Reviewed-by: default avatarYutaka Hirano <yhirano@chromium.org>
Commit-Queue: Yoichi Osato <yoichio@chromium.org>
Cr-Commit-Position: refs/heads/master@{#738799}
parent 9b611ff9
...@@ -30,12 +30,12 @@ script_tests_path = os.path.join(top_path, 'script-tests') ...@@ -30,12 +30,12 @@ script_tests_path = os.path.join(top_path, 'script-tests')
def generate(output_path, template_path, context, testname, options): def generate(output_path, template_path, context, testname, options):
output_basename = testname + options + '.html' output_basename = testname + options + '.html'
with open(template_path, 'r') as template_file: with open(template_path, 'rb') as template_file:
template_data = template_file.read() template_data = template_file.read()
output_data = re.sub(r'TESTNAME', testname, template_data) output_data = re.sub(r'TESTNAME', testname, template_data)
output_data = re.sub(r'OPTIONS', options, output_data) output_data = re.sub(r'OPTIONS', options, output_data)
with open(os.path.join(output_path, output_basename), 'w') as output_file: with open(os.path.join(output_path, output_basename), 'wb') as output_file:
output_file.write(output_data) output_file.write(output_data)
...@@ -48,7 +48,7 @@ def generate_directory(relative_path, contexts, original_options): ...@@ -48,7 +48,7 @@ def generate_directory(relative_path, contexts, original_options):
options = original_options options = original_options
# Read OPTIONS list. # Read OPTIONS list.
with open(os.path.join(directory_path, script), 'r') as script_file: with open(os.path.join(directory_path, script), 'rb') as script_file:
script = script_file.read() script = script_file.read()
m = re.search(r'// *OPTIONS: *([a-z\-,]*)', script) m = re.search(r'// *OPTIONS: *([a-z\-,]*)', script)
if m: if m:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment