本文整理汇总了Python中jedi.Script._get_module方法的典型用法代码示例。如果您正苦于以下问题:Python Script._get_module方法的具体用法?Python Script._get_module怎么用?Python Script._get_module使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jedi.Script
的用法示例。
在下文中一共展示了Script._get_module方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from jedi import Script [as 别名]
# 或者: from jedi.Script import _get_module [as 别名]
class Traverser:
def __init__(self):
self._script = Script('', 1, 0, 'example.py')
self._module = self._script._get_module()
def names_in_module(self, module_name):
try:
_import_module(module_name)
except Exception as e:
pp.pprint(e)
return []
imp = Importer(
self._script._evaluator, [FakeName('.'.join(module_name))],
self._module, 0)
try:
scope_set = imp.follow()
except Exception as e:
# print('Error "{}" in {}, ignoring...'.format(e, module_name))
return []
all_names = []
for s in scope_set:
names = []
for names_dict in s.names_dicts(search_global=False):
names += chain.from_iterable(names_dict.values())
all_names += finder.filter_definition_names(names, self._module)
return all_names
示例2: paths
# 需要导入模块: from jedi import Script [as 别名]
# 或者: from jedi.Script import _get_module [as 别名]
def paths(src):
script = Script(src)
expr_stmt = script._get_module_node().children[0].children[0]
return set(sys_path._paths_from_assignment(script._get_module(), expr_stmt))
示例3: paths
# 需要导入模块: from jedi import Script [as 别名]
# 或者: from jedi.Script import _get_module [as 别名]
def paths(src):
script = Script(src)
stmt = script._get_module_node().statements[0]
return set(sys_path._paths_from_assignment(script._get_module(), stmt))
示例4: test_equals
# 需要导入模块: from jedi import Script [as 别名]
# 或者: from jedi.Script import _get_module [as 别名]
def test_equals(source):
script = Script(source)
node = script._get_module_node().children[0].children[0]
first, = script._get_module().eval_node(node)
assert isinstance(first, CompiledObject) and first.obj is True