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


Python Script.call_signatures方法代码示例

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


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

示例1: do_complete

# 需要导入模块: from jedi import Script [as 别名]
# 或者: from jedi.Script import call_signatures [as 别名]
    def do_complete(self, data):
        file_ = self.db.get_file(self.current_file)
        file_ = to_unicode(file_)
        lines = file_.splitlines()
        lno = self.current['lno']
        line_before = ''
        if len(lines) >= lno:
            line_before = lines[lno - 1]
        indent = len(line_before) - len(line_before.lstrip())
        segments = data.splitlines()
        for segment in reversed(segments):
            line = u(' ') * indent + segment
            lines.insert(lno - 1, line)
        script = Script(
            u('\n').join(lines), lno - 1 + len(segments),
            len(segments[-1]) + indent, '')
        try:
            completions = script.completions()
        except Exception:
            self.db.send('Suggest')
            self.notify_exc('Completion failed for %s' % (
                '\n'.join(reversed(segments))))
            return

        try:
            funs = script.call_signatures() or []
        except Exception:
            self.db.send('Suggest')
            self.notify_exc('Completion of function failed for %s' % (
                '\n'.join(reversed(segments))))
            return

        try:
            suggest_obj = {
                'params': [{
                    'params': [p.get_code().replace('\n', '')
                               for p in fun.params],
                    'index': fun.index,
                    'module': fun.module.path,
                    'call_name': fun.call_name} for fun in funs],
                'completions': [{
                    'base': comp.name[
                        :len(comp.name) - len(comp.complete)],
                    'complete': comp.complete,
                    'description': comp.description
                } for comp in completions if comp.name.endswith(
                    comp.complete)]
            }
            self.db.send('Suggest|%s' % dump(suggest_obj))
        except Exception:
            self.db.send('Suggest')
            self.notify_exc('Completion generation failed for %s' % (
                '\n'.join(reversed(segments))))
开发者ID:Avinash9,项目名称:wdb,代码行数:55,代码来源:ui.py

示例2: test_dict_literal_in_incomplete_call

# 需要导入模块: from jedi import Script [as 别名]
# 或者: from jedi.Script import call_signatures [as 别名]
def test_dict_literal_in_incomplete_call():
    source = """\
    import json

    def foo():
        json.loads(

        json.load.return_value = {'foo': [],
                                  'bar': True}

        c = Foo()
    """

    script = Script(dedent(source), line=4, column=15)
    assert script.call_signatures()
开发者ID:ABob,项目名称:vim,代码行数:17,代码来源:test_call_signatures.py


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