diff --git a/edbob/files.py b/edbob/files.py index 886fcec..f3501ba 100644 --- a/edbob/files.py +++ b/edbob/files.py @@ -36,6 +36,15 @@ import tempfile __all__ = ['change_newlines', 'count_lines', 'temp_path'] +class DosFile(file): + """ + Subclass of ``file`` which uses DOS line endings when writing the file. + """ + + def write(self, string): + super(DosFile, self).write(string.replace(os.linesep, '\r\n')) + + def change_newlines(path, newline): """ Rewrites the file at ``path``, changing its newline character(s) to that of