146
147
module_path=child_path, member=None,
147
148
children=grandchildren)
152
def _convert_import_str_to_map(import_str, imports):
153
"""This converts a import string into a list of imports.
155
This only understands 'import foo, foo.bar, foo.bar.baz as bing'
157
:param import_str: The import string to process
158
:param imports: The current map of all imports
160
assert import_str.startswith('import ')
161
import_str = import_str[len('import '):]
163
for path in import_str.split(','):
165
as_hunks = path.split(' as ')
166
if len(as_hunks) == 2:
167
# We have 'as' so this is a different style of import
168
# 'import foo.bar.baz as bing' creates a local variable
169
# named 'bing' which points to 'foo.bar.baz'
170
name = as_hunks[1].strip()
171
module_path = as_hunks[0].strip().split('.')
172
assert name not in imports
173
# No children available in 'import foo as bar'
174
imports[name] = (module_path, None, {})
176
# Now we need to handle
177
module_path = path.split('.')
178
name = module_path[0]
179
if name not in imports:
180
# This is a new import that we haven't seen before
181
module_def = ([name], None, {})
182
imports[name] = module_def
184
module_def = imports[name]
188
for child in module_path[1:]:
189
cur_path.append(child)
193
next = (cur_path[:], None, {})