Fix line endings on Windows
parent
023d53b986
commit
33a308cc3d
|
@ -99,7 +99,7 @@ class TemplateFile:
|
|||
"""
|
||||
def merge_and_save(self):
|
||||
self.previous_catalog.merge(self.current_catalog)
|
||||
self.previous_catalog.save(self.file_name)
|
||||
self.previous_catalog.save(self.file_name, newline='\n')
|
||||
|
||||
"""
|
||||
Wrapper class over POFile, acting as language translation file
|
||||
|
@ -135,7 +135,7 @@ class LanguageFile:
|
|||
"""
|
||||
def merge_and_save(self, template_file):
|
||||
self.catalog.merge(template_file.current_catalog)
|
||||
self.catalog.save(self.file_name)
|
||||
self.catalog.save(self.file_name, newline='\n')
|
||||
|
||||
"""
|
||||
Locates the translation files in po_dir
|
||||
|
@ -208,9 +208,9 @@ class TranslationJob:
|
|||
self._close_files()
|
||||
|
||||
def _open_files(self):
|
||||
self._input_file = io.open(self._input_file_name, 'r', encoding='utf-8')
|
||||
self._input_file = io.open(self._input_file_name, 'r', encoding='utf-8', newline='\n')
|
||||
if self._output_file_name:
|
||||
self._output_file = io.open(self._output_file_name, 'w', encoding='utf-8')
|
||||
self._output_file = io.open(self._output_file_name, 'w', encoding='utf-8', newline='\n')
|
||||
|
||||
def _close_files(self):
|
||||
self._input_file.close()
|
||||
|
|
|
@ -405,7 +405,7 @@ class _BaseFile(list):
|
|||
e.flags.append('fuzzy')
|
||||
return e
|
||||
|
||||
def save(self, fpath=None, repr_method='__unicode__'):
|
||||
def save(self, fpath=None, repr_method='__unicode__', newline=None):
|
||||
"""
|
||||
Saves the po file to ``fpath``.
|
||||
If it is an existing file and no ``fpath`` is provided, then the
|
||||
|
@ -427,7 +427,7 @@ class _BaseFile(list):
|
|||
if repr_method == 'to_binary':
|
||||
fhandle = open(fpath, 'wb')
|
||||
else:
|
||||
fhandle = io.open(fpath, 'w', encoding=self.encoding)
|
||||
fhandle = io.open(fpath, 'w', encoding=self.encoding, newline=newline)
|
||||
if not isinstance(contents, text_type):
|
||||
contents = contents.decode(self.encoding)
|
||||
fhandle.write(contents)
|
||||
|
|
Loading…
Reference in New Issue