add DosFile class for writing DOS files

This commit is contained in:
Lance Edgar 2012-08-09 09:39:37 -07:00
parent aa4d536f5e
commit 9fc804f64f

View file

@ -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