pyclbr, ModuleParser: reworked the fix contributed by Tobias and fixed an issue introduced by it.

Sun, 24 Feb 2019 13:01:43 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 24 Feb 2019 13:01:43 +0100
changeset 6815
b1b833693a38
parent 6814
7640753ca46e
child 6816
d1a6f7fc6dd2

pyclbr, ModuleParser: reworked the fix contributed by Tobias and fixed an issue introduced by it.

Utilities/ClassBrowsers/pyclbr.py file | annotate | diff | comparison | revisions
Utilities/ModuleParser.py file | annotate | diff | comparison | revisions
--- a/Utilities/ClassBrowsers/pyclbr.py	Sun Feb 24 12:13:56 2019 +0100
+++ b/Utilities/ClassBrowsers/pyclbr.py	Sun Feb 24 13:01:43 2019 +0100
@@ -31,7 +31,7 @@
 _getnext = re.compile(
     r"""
     (?P<String>
-        \#[^\n]*$   # Ignore triple quotes in comments
+        \# .*? $   # ignore everything in comments
     |
         \""" [^"\\]* (?:
                         (?: \\. | "(?!"") )
--- a/Utilities/ModuleParser.py	Sun Feb 24 12:13:56 2019 +0100
+++ b/Utilities/ModuleParser.py	Sun Feb 24 13:01:43 2019 +0100
@@ -60,7 +60,7 @@
 _py_getnext = re.compile(
     r"""
     (?P<Comment>
-        \#[^\n]*$   # Ignore triple quotes in comments
+        \# .*? $   # ignore everything in comments
     )
     
 |   (?P<String>
@@ -532,7 +532,7 @@
         deltaindent = 0
         deltaindentcalculated = 0
         i = 0
-        modulelevel = 1
+        modulelevel = True
         cur_obj = self
         modifierType = Function.General
         modifierIndent = -1
@@ -652,7 +652,7 @@
                     if self.file.lower().endswith('.ptl'):
                         contents = ""
                     else:
-                        contents = 1 and m.group("DocstringContents1") \
+                        contents = m.group("DocstringContents1") \
                             or m.group("DocstringContents2")
                 if cur_obj:
                     cur_obj.addDescription(contents)
@@ -669,7 +669,7 @@
                         if self.file.lower().endswith('.ptl'):
                             contents = ""
                         else:
-                            contents = 1 and m.group("StringContents1") \
+                            contents = m.group("StringContents1") \
                                 or m.group("StringContents2")
                     if cur_obj:
                         cur_obj.addDescription(contents)
@@ -818,12 +818,13 @@
                 deltaindentcalculated = 0
             
             elif m.start("Comment") >= 0:
-                pass
+                if modulelevel:
+                    continue
             
             else:
                 assert 0, "regexp _getnext found something unexpected"
             
-            modulelevel = 0
+            modulelevel = False
     
     def __rb_scan(self, src):
         """

eric ide

mercurial