jenkins-bot has submitted this change and it was merged.
Change subject: Remove broken linebreak fixes ......................................................................
Remove broken linebreak fixes
Python's universal newline should already take care of this; in addition to that, they were the wrong way around -- changing '\n' to '\r\n' when reading the file (while this should have been the other way around).
This code was originally implemented in https://www.mediawiki.org/wiki/Special:Code/pywikipedia/3739
Change-Id: I78d97cdeb4632a038bc4c9eb1c9be67a63dfbed4 --- M pywikibot/editor.py 1 file changed, 2 insertions(+), 24 deletions(-)
Approvals: XZise: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/editor.py b/pywikibot/editor.py index 1f877e3..d3e268a 100644 --- a/pywikibot/editor.py +++ b/pywikibot/editor.py @@ -11,7 +11,6 @@ __version__ = '$Id$' #
-import sys import os import tempfile import codecs @@ -57,22 +56,6 @@ pywikibot.log(u'Running editor: %s' % command) return command
- def convertLinebreaks(self, text): - """Convert line-breaks.""" - if sys.platform == 'win32': - return text.replace('\r\n', '\n') - # TODO: Mac OS handling - return text - - def restoreLinebreaks(self, text): - """Restore line-breaks.""" - if text is None: - return - if sys.platform == 'win32': - return text.replace('\n', '\r\n') - # TODO: Mac OS handling - return text - def edit(self, text, jumpIndex=None, highlight=None): """ Call the editor and thus allows the user to change the text. @@ -89,7 +72,6 @@ file in his text editor @rtype: unicode or None """ - text = self.convertLinebreaks(text) if config.editor: tempFilename = '%s.%s' % (tempfile.mktemp(), config.editor_filename_extension) @@ -108,7 +90,7 @@ encoding=config.editor_encoding) as temp_file: newcontent = temp_file.read() os.unlink(tempFilename) - return self.restoreLinebreaks(newcontent) + return newcontent
try: import gui # noqa @@ -120,8 +102,4 @@ 'are typically part of Python but may be packaged separately ' 'on your platform.\n' % e)
- return self.restoreLinebreaks( - pywikibot.ui.editText( - text, - jumpIndex=jumpIndex, - highlight=highlight)) + return pywikibot.ui.editText(text, jumpIndex=jumpIndex, highlight=highlight)
pywikibot-commits@lists.wikimedia.org