Skip to content

Commit

Permalink
Merge pull request #30 from daltonmaag/lf-eol
Browse files Browse the repository at this point in the history
always use Unix LF end of lines
  • Loading branch information
typesupply committed Apr 7, 2016
2 parents 1ac5c43 + 3160ae4 commit aa62116
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 8 additions & 0 deletions normalization/test_ufonormalizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1664,6 +1664,14 @@ def test_subpathWriteFile(self):
text = f.read()
self.assertEqual(text, expected_text)

def test_subpathWriteFile_newline(self):
mixed_eol_text = 'foo\r\nbar\nbaz\rquz'
expected_text = 'foo\nbar\nbaz\nquz'
subpathWriteFile(mixed_eol_text, self.directory, self.filename)
with open(self.filepath, 'r', encoding='utf-8') as f:
text = f.read()
self.assertEqual(text, expected_text)

def test_subpathWritePlist(self):
expected_data = dict([('a', 'foo'), ('b', 'bar'), ('c', '™')])
subpathWritePlist(expected_data, self.directory, self.plistname)
Expand Down
3 changes: 2 additions & 1 deletion normalization/ufonormalizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1369,7 +1369,8 @@ def subpathWriteFile(text, ufoPath, *subpath):
existing = None

if text != existing:
with open(path, "w", encoding="utf-8") as f:
# always use Unix LF end of lines
with open(path, "w", encoding="utf-8", newline="\n") as f:
f.write(text)

def subpathWritePlist(data, ufoPath, *subpath):
Expand Down

0 comments on commit aa62116

Please sign in to comment.