|
38 | 38 | import re |
39 | 39 | import string |
40 | 40 |
|
41 | | -id = '(?P<id>[A-Za-z_][A-Za-z0-9_]*)' # match identifier |
| 41 | +id = '[A-Za-z_][A-Za-z0-9_]*' # match identifier |
42 | 42 | blank_line = re.compile('^[ \t]*($|#)') |
43 | | -is_class = re.compile('^class[ \t]+'+id+'[ \t]*(?P<sup>\([^)]*\))?[ \t]*:') |
44 | | -is_method = re.compile('^[ \t]+def[ \t]+'+id+'[ \t]*\(') |
| 43 | +is_class = re.compile('^class[ \t]+(?P<id>'+id+')[ \t]*(?P<sup>\([^)]*\))?[ \t]*:') |
| 44 | +is_method = re.compile('^[ \t]+def[ \t]+(?P<id>'+id+')[ \t]*\(') |
45 | 45 | is_import = re.compile('^import[ \t]*(?P<imp>[^#]+)') |
46 | | -is_from = re.compile('^from[ \t]+'+id+'[ \t]+import[ \t]+(?P<imp>[^#]+)') |
| 46 | +is_from = re.compile('^from[ \t]+(?P<module>'+id+'([ \t]*\\.[ \t]*'+id+')*)[ \t]+import[ \t]+(?P<imp>[^#]+)') |
47 | 47 | dedent = re.compile('^[^ \t]') |
48 | 48 | indent = re.compile('^[^ \t]*') |
49 | 49 |
|
@@ -75,8 +75,8 @@ def readmodule(module, path=[], inpackage=0): |
75 | 75 | i = string.rfind(module, '.') |
76 | 76 | if i >= 0: |
77 | 77 | # Dotted module name |
78 | | - package = module[:i] |
79 | | - submodule = module[i+1:] |
| 78 | + package = string.strip(module[:i]) |
| 79 | + submodule = string.strip(module[i+1:]) |
80 | 80 | parent = readmodule(package, path, inpackage) |
81 | 81 | child = readmodule(submodule, parent['__path__'], 1) |
82 | 82 | return child |
@@ -146,7 +146,7 @@ def readmodule(module, path=[], inpackage=0): |
146 | 146 | res = is_from.match(line) |
147 | 147 | if res: |
148 | 148 | # from module import stuff |
149 | | - mod = res.group('id') |
| 149 | + mod = res.group('module') |
150 | 150 | names = string.splitfields(res.group('imp'), ',') |
151 | 151 | try: |
152 | 152 | # recursively read the imported module |
|
0 commit comments