MCPcopy Create free account
hub / github.com/scottrogowski/code2flow / process_import

Function process_import

code2flow/python.py:85–104  ·  view source on GitHub ↗

Given an element from the ast which is an import statement, return a Variable that points_to the module being imported. For now, the points_to is a string but that is resolved later. :param element ast: :rtype: Variable

(element)

Source from the content-addressed store, hash-verified

83
84
85def process_import(element):
86 """
87 Given an element from the ast which is an import statement, return a
88 Variable that points_to the module being imported. For now, the
89 points_to is a string but that is resolved later.
90
91 :param element ast:
92 :rtype: Variable
93 """
94 ret = []
95
96 for single_import in element.names:
97 assert isinstance(single_import, ast.alias)
98 token = single_import.asname or single_import.name
99 rhs = single_import.name
100
101 if hasattr(element, 'module') and element.module:
102 rhs = djoin(element.module, rhs)
103 ret.append(Variable(token, points_to=rhs, line_number=element.lineno))
104 return ret
105
106
107def make_local_variables(lines, parent):

Callers 1

make_local_variablesFunction · 0.85

Calls 2

djoinFunction · 0.85
VariableClass · 0.85

Tested by

no test coverage detected