rebaseline_server: write JSON files using Unix line endings, even on Windows
(SkipBuildbotRuns)
BUG=skia:1815
NOTRY=True
NOTREECHECKS=True
R=bsalomon@google.com, epoger@google.com
Author: epoger@gmail.com
Review URL: https://codereview.chromium.org/117783004
git-svn-id: http://skia.googlecode.com/svn/trunk@12739 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gm/gm_json.py b/gm/gm_json.py
index 1d8da9f..2c37d6a 100644
--- a/gm/gm_json.py
+++ b/gm/gm_json.py
@@ -12,6 +12,7 @@
# system-level imports
+import io
import json
import os
@@ -124,6 +125,10 @@
return LoadFromString(file_contents)
def WriteToFile(json_dict, file_path):
- """Writes the JSON summary in json_dict out to file_path."""
- with open(file_path, 'w') as outfile:
- json.dump(json_dict, outfile, sort_keys=True, indent=2)
+ """Writes the JSON summary in json_dict out to file_path.
+
+ The file is written Unix-style (each line ends with just LF, not CRLF);
+ see https://code.google.com/p/skia/issues/detail?id=1815 for reasons."""
+ with io.open(file_path, mode='w', newline='', encoding='utf-8') as outfile:
+ outfile.write(unicode(json.dumps(json_dict, outfile, sort_keys=True,
+ indent=2)))