Commit 06884363 authored by Guido van Rossum's avatar Guido van Rossum

Enhancements by Sjoerd Mullender: support for

	from a.b import c
	import a . b
parent 7a840e8d
...@@ -38,12 +38,12 @@ import imp ...@@ -38,12 +38,12 @@ import imp
import re import re
import string import string
id = '(?P<id>[A-Za-z_][A-Za-z0-9_]*)' # match identifier id = '[A-Za-z_][A-Za-z0-9_]*' # match identifier
blank_line = re.compile('^[ \t]*($|#)') blank_line = re.compile('^[ \t]*($|#)')
is_class = re.compile('^class[ \t]+'+id+'[ \t]*(?P<sup>\([^)]*\))?[ \t]*:') is_class = re.compile('^class[ \t]+(?P<id>'+id+')[ \t]*(?P<sup>\([^)]*\))?[ \t]*:')
is_method = re.compile('^[ \t]+def[ \t]+'+id+'[ \t]*\(') is_method = re.compile('^[ \t]+def[ \t]+(?P<id>'+id+')[ \t]*\(')
is_import = re.compile('^import[ \t]*(?P<imp>[^#]+)') is_import = re.compile('^import[ \t]*(?P<imp>[^#]+)')
is_from = re.compile('^from[ \t]+'+id+'[ \t]+import[ \t]+(?P<imp>[^#]+)') is_from = re.compile('^from[ \t]+(?P<module>'+id+'([ \t]*\\.[ \t]*'+id+')*)[ \t]+import[ \t]+(?P<imp>[^#]+)')
dedent = re.compile('^[^ \t]') dedent = re.compile('^[^ \t]')
indent = re.compile('^[^ \t]*') indent = re.compile('^[^ \t]*')
...@@ -75,8 +75,8 @@ def readmodule(module, path=[], inpackage=0): ...@@ -75,8 +75,8 @@ def readmodule(module, path=[], inpackage=0):
i = string.rfind(module, '.') i = string.rfind(module, '.')
if i >= 0: if i >= 0:
# Dotted module name # Dotted module name
package = module[:i] package = string.strip(module[:i])
submodule = module[i+1:] submodule = string.strip(module[i+1:])
parent = readmodule(package, path, inpackage) parent = readmodule(package, path, inpackage)
child = readmodule(submodule, parent['__path__'], 1) child = readmodule(submodule, parent['__path__'], 1)
return child return child
...@@ -146,7 +146,7 @@ def readmodule(module, path=[], inpackage=0): ...@@ -146,7 +146,7 @@ def readmodule(module, path=[], inpackage=0):
res = is_from.match(line) res = is_from.match(line)
if res: if res:
# from module import stuff # from module import stuff
mod = res.group('id') mod = res.group('module')
names = string.splitfields(res.group('imp'), ',') names = string.splitfields(res.group('imp'), ',')
try: try:
# recursively read the imported module # recursively read the imported module
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment