From 9fc804f64f504b482b016535352afc7359e68c82 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Thu, 9 Aug 2012 09:39:37 -0700 Subject: [PATCH] add DosFile class for writing DOS files --- edbob/files.py | 9 +++++++++ 1 file changed, 9 insertions(+) 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