Utilities/ModuleParser.py

branch
5_1_x
changeset 1352
0d0d42ee74c4
parent 841
0d379ff260df
child 1510
e75ecf2bd9dd
diff -r 42a477f873db -r 0d0d42ee74c4 Utilities/ModuleParser.py
--- a/Utilities/ModuleParser.py	Sun Oct 02 15:59:23 2011 +0200
+++ b/Utilities/ModuleParser.py	Sun Oct 02 15:57:38 2011 +0200
@@ -137,20 +137,20 @@
 
 |   (?P<Import>
         ^ (?: import | from [ \t]+ \. [ \t]+ import ) [ \t]+
-        (?P<ImportList> [^#;\n]+ )
+        (?P<ImportList> (?: [^#;\\\n]+ (?: \\\n )* )* )
     )
 
 |   (?P<ImportFrom>
         ^ from [ \t]+
         (?P<ImportFromPath>
-            \w+
+            \.* \w+
             (?:
                 [ \t]* \. [ \t]* \w+
             )*
         )
         [ \t]+
         import [ \t]+
-        (?P<ImportFromList> [^#;\n]+ )
+        (?P<ImportFromList> (?: [^#;\\\n]+ (?: \\\n )* )* )
     )
 
 |   (?P<ConditionalDefine>
@@ -677,20 +677,20 @@
 
             elif m.start("Import") >= 0:
                 # import module
-                for name in m.group("ImportList").split(','):
-                    name = name.strip()
+                names = [n.strip() for n in "".join(
+                    m.group("ImportList").splitlines()).replace("\\", "").split(',')]
+                for name in names:
                     if not name in self.imports:
                         self.imports.append(name)
             
             elif m.start("ImportFrom") >= 0:
                 # from module import stuff
                 mod = m.group("ImportFromPath")
-                names = m.group("ImportFromList").split(',')
+                names = [n.strip() for n in "".join(
+                    m.group("ImportFromList").splitlines()).replace("\\", "").split(',')]
                 if mod not in self.from_imports:
                     self.from_imports[mod] = []
-                for n in names:
-                    n = n.strip()
-                    self.from_imports[mod].append(n)
+                self.from_imports[mod].extend(names)
             
             elif m.start("ConditionalDefine") >= 0:
                 # a conditional function/method definition

eric ide

mercurial