Fixed an issue in the code style fixer related to docstrings enclosed in ' or " quotes. 6_0_x

Mon, 02 Mar 2015 19:02:05 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 02 Mar 2015 19:02:05 +0100
branch
6_0_x
changeset 4151
9f85001478de
parent 4149
b876fbf55438
child 4157
00d12a3a5f2d

Fixed an issue in the code style fixer related to docstrings enclosed in ' or " quotes.
(grafted from a0cece581ad084f614750ac0fb3d71d4fe36b1e5)

Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleFixer.py file | annotate | diff | comparison | revisions
--- a/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleFixer.py	Sun Mar 01 17:10:40 2015 +0100
+++ b/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleFixer.py	Mon Mar 02 19:02:05 2015 +0100
@@ -512,11 +512,13 @@
             fix (integer)
         """
         line = line - 1
-        left, right = self.__source[line].split("'''", 1)
+        quotes = re.match(r"""\s*[ru]?('''|'|\")""",
+                          self.__source[line]).group(1)
+        left, right = self.__source[line].split(quotes, 1)
         self.__source[line] = left + '"""' + right
         while line < len(self.__source):
-            if self.__source[line].rstrip().endswith("'''"):
-                left, right = self.__source[line].rsplit("'''", 1)
+            if self.__source[line].rstrip().endswith(quotes):
+                left, right = self.__source[line].rsplit(quotes, 1)
                 self.__source[line] = left + '"""' + right
                 break
             line += 1

eric ide

mercurial