Fixed some issues in the code style fixer.

Wed, 02 Oct 2013 18:58:13 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 02 Oct 2013 18:58:13 +0200
changeset 2981
0c5205aa7a5a
parent 2980
2cb4e3c50b37
child 2982
556adfe76ba7

Fixed some issues in the code style fixer.

Plugins/CheckerPlugins/Pep8/CodeStyleFixer.py file | annotate | diff | comparison | revisions
--- a/Plugins/CheckerPlugins/Pep8/CodeStyleFixer.py	Tue Oct 01 18:42:42 2013 +0200
+++ b/Plugins/CheckerPlugins/Pep8/CodeStyleFixer.py	Wed Oct 02 18:58:13 2013 +0200
@@ -1517,6 +1517,8 @@
                 if newText != text:
                     self.__source[line] = newText
                 if newNextText and newNextText != nextText:
+                    if newNextText == " ":
+                        newNextText = ""
                     self.__source[line + 1] = newNextText
                 return (1, self.trUtf8("Long lines have been shortened."), 0)
             else:
@@ -2483,14 +2485,21 @@
             second = self.__text[blank:].strip()
             if newNext.strip():
                 newText = first + self.__eol
-                newNext = self.__getIndent(newNext) + \
-                    second + " " + newNext.lstrip()
+                if second.endswith(")"):
+                    # don't merge with next line
+                    newText += self.__getIndent(newText) + second + self.__eol
+                    newNext = ""
+                else:
+                    newNext = self.__getIndent(newNext) + \
+                        second + " " + newNext.lstrip()
             else:
                 # empty line, add a new line
                 newText = first + self.__eol
                 newNext = self.__getIndent(newNext) + \
                     second + self.__eol + newNext.lstrip()
-        return newText, newNext
+            return newText, newNext
+        else:
+            return None
     
     def __isProbablyInsideStringOrComment(self, line, index):
         """
@@ -2570,7 +2579,7 @@
                 if first.rstrip().endswith('.'):
                     continue
                 
-                if tokenString in '+-*/':
+                if tokenString in '+-*/,':
                     newText = first + ' \\' + self.__eol + second
                 else:
                     newText = first + self.__eol + second

eric ide

mercurial