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
This commit is contained in:
commit-bot@chromium.org 2013-12-18 15:28:24 +00:00
parent d9947f605a
commit 83aaf88b99

View File

@ -12,6 +12,7 @@ __author__ = 'Elliot Poger'
# system-level imports
import io
import json
import os
@ -124,6 +125,10 @@ def LoadFromFile(file_path):
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)))