forked from VimPlug/jedi
Import.paths -> Import.get_paths.
This commit is contained in:
@@ -342,7 +342,7 @@ class Script(object):
|
|||||||
elif isinstance(node, tree.Import):
|
elif isinstance(node, tree.Import):
|
||||||
import_names = set(node.get_defined_names())
|
import_names = set(node.get_defined_names())
|
||||||
if node.is_nested():
|
if node.is_nested():
|
||||||
import_names |= set(path[-1] for path in node.paths())
|
import_names |= set(path[-1] for path in node.get_paths())
|
||||||
for n in import_names:
|
for n in import_names:
|
||||||
imports.infer_import(context, n)
|
imports.infer_import(context, n)
|
||||||
elif node.type == 'expr_stmt':
|
elif node.type == 'expr_stmt':
|
||||||
|
|||||||
@@ -294,7 +294,7 @@ class Module(Scope):
|
|||||||
# the future print statement).
|
# the future print statement).
|
||||||
for imp in self.iter_imports():
|
for imp in self.iter_imports():
|
||||||
if imp.type == 'import_from' and imp.level == 0:
|
if imp.type == 'import_from' and imp.level == 0:
|
||||||
for path in imp.paths():
|
for path in imp.get_paths():
|
||||||
names = [name.value for name in path]
|
names = [name.value for name in path]
|
||||||
if len(names) == 2 and names[0] == '__future__':
|
if len(names) == 2 and names[0] == '__future__':
|
||||||
yield names[1]
|
yield names[1]
|
||||||
@@ -674,7 +674,7 @@ class Import(PythonBaseNode):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
for path in self.paths():
|
for path in self.get_paths():
|
||||||
if name in path:
|
if name in path:
|
||||||
return path[:path.index(name) + 1]
|
return path[:path.index(name) + 1]
|
||||||
raise ValueError('Name should be defined in the import itself')
|
raise ValueError('Name should be defined in the import itself')
|
||||||
@@ -746,9 +746,9 @@ class ImportFrom(Import):
|
|||||||
"""
|
"""
|
||||||
The last name defined in a star import.
|
The last name defined in a star import.
|
||||||
"""
|
"""
|
||||||
return self.paths()[-1][-1]
|
return self.get_paths()[-1][-1]
|
||||||
|
|
||||||
def paths(self):
|
def get_paths(self):
|
||||||
"""
|
"""
|
||||||
The import paths defined in an import statement. Typically an array
|
The import paths defined in an import statement. Typically an array
|
||||||
like this: ``[<Name: datetime>, <Name: date>]``.
|
like this: ``[<Name: datetime>, <Name: date>]``.
|
||||||
@@ -778,7 +778,7 @@ class ImportName(Import):
|
|||||||
"""The level parameter of ``__import__``."""
|
"""The level parameter of ``__import__``."""
|
||||||
return 0 # Obviously 0 for imports without from.
|
return 0 # Obviously 0 for imports without from.
|
||||||
|
|
||||||
def paths(self):
|
def get_paths(self):
|
||||||
return [path for path, alias in self._dotted_as_names()]
|
return [path for path, alias in self._dotted_as_names()]
|
||||||
|
|
||||||
def _dotted_as_names(self):
|
def _dotted_as_names(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user