当前位置: 首页>>代码示例>>Python>>正文


Python Script.goto_assignments方法代码示例

本文整理汇总了Python中jedi.Script.goto_assignments方法的典型用法代码示例。如果您正苦于以下问题:Python Script.goto_assignments方法的具体用法?Python Script.goto_assignments怎么用?Python Script.goto_assignments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在jedi.Script的用法示例。


在下文中一共展示了Script.goto_assignments方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _validate_import

# 需要导入模块: from jedi import Script [as 别名]
# 或者: from jedi.Script import goto_assignments [as 别名]
    def _validate_import(self, module_line, lineno):
        """Try to validate the given iport line
        """

        if 'noqa' in module_line:
            return True

        error = []
        error_string = 'can\'t import {0}'
        valid = True
        for word in module_line.split():
            if word in ('from', 'import', 'as'):
                continue

            offset = int(module_line.find(word) + len(word) / 2)
            s = Script(self.source, lineno, offset, self.filename)
            if not self.filename:
                s = Script(module_line, 1, offset)

            if not s.goto_assignments():
                if valid is True:
                    valid = False
                error.append(word)

        err = '' if valid else error_string.format(' '.join(error))
        return err, valid
开发者ID:DamnWidget,项目名称:anaconda,代码行数:28,代码来源:import_validator.py

示例2: make_definitions

# 需要导入模块: from jedi import Script [as 别名]
# 或者: from jedi.Script import goto_assignments [as 别名]
def make_definitions():
    """
    Return a list of definitions for parametrized tests.

    :rtype: [jedi.api_classes.BaseDefinition]
    """
    source = dedent(
        """
    import sys

    class C:
        pass

    x = C()

    def f():
        pass

    def g():
        yield

    h = lambda: None
    """
    )

    definitions = []
    definitions += defined_names(source)

    source += dedent(
        """
    variable = sys or C or x or f or g or g() or h"""
    )
    lines = source.splitlines()
    script = Script(source, len(lines), len("variable"), None)
    definitions += script.goto_definitions()

    script2 = Script(source, 4, len("class C"), None)
    definitions += script2.usages()

    source_param = "def f(a): return a"
    script_param = Script(source_param, 1, len(source_param), None)
    definitions += script_param.goto_assignments()

    return definitions
开发者ID:,项目名称:,代码行数:46,代码来源:


注:本文中的jedi.Script.goto_assignments方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。