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


Python Script.get_in_function_call方法代码示例

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


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

示例1: run

# 需要导入模块: from jedi import Script [as 别名]
# 或者: from jedi.Script import get_in_function_call [as 别名]
 def run(self, *args, **kwargs):
     request = self.__request
     script = Script(request.source_code, request.line, request.col,
                     request.filename, request.encoding)
     try:
         call = script.get_in_function_call()
         if call:
             self.resultsAvailable.signal.emit(call, request)
         else:
             self.failedEvent.signal.emit()
     except:
         self.failedEvent.signal.emit()
开发者ID:hofoen,项目名称:pcef-core,代码行数:14,代码来源:calltips.py

示例2: do_complete

# 需要导入模块: from jedi import Script [as 别名]
# 或者: from jedi.Script import get_in_function_call [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.complete()
     except:
         log.info('Completion failed', exc_info=True)
         self.db.send('Log|%s' % dump({
             'message': 'Completion failed for %s' %
             '\n'.join(reversed(segments))
         }))
     else:
         fun = script.get_in_function_call()
         self.db.send('Suggest|%s' % dump({
             'params': {
                 'params': [p.get_code().replace('\n', '')
                            for p in fun.params],
                 'index': fun.index,
                 'module': fun.module.path,
                 'call_name': fun.call_name} if fun else None,
             'completions': [{
                 'base': comp.word[
                     :len(comp.word) - len(comp.complete)],
                 'complete': comp.complete,
                 'description': comp.description
             } for comp in completions if comp.word.endswith(
                 comp.complete)]
         }))
开发者ID:TFenby,项目名称:wdb,代码行数:43,代码来源:ui.py

示例3: _interaction

# 需要导入模块: from jedi import Script [as 别名]
# 或者: from jedi.Script import get_in_function_call [as 别名]

#.........这里部分代码省略.........
                    lno, cond = lno.split(',')
                    cond = cond.lstrip()

                lno = int(lno)
                rv = self.set_break(fn, lno, int(cmd == 'TBreak'), cond)
                if rv is not None:
                    for path in sys.path:
                        rv = self.set_break(
                            os.path.join(path, fn),
                            lno, int(cmd == 'TBreak'), cond)
                        if rv is None:
                            break
                if rv is None:
                    log.info('Break set at %s:%d [%s]' % (fn, lno, rv))
                    if fn == current['file']:
                        self.send('BreakSet|%s' % dump({
                            'lno': lno, 'cond': cond
                        }))
                    else:
                        self.send('BreakSet|%s' % dump({}))
                else:
                    self.send('Log|%s' % dump({
                        'message': rv
                    }))

            elif cmd == 'Unbreak':
                lno = int(data)
                current_file = current['file']
                log.info('Break unset at %s:%d' % (current_file, lno))
                self.clear_break(current_file, lno)
                self.send('BreakUnset|%s' % dump({'lno': lno}))

            elif cmd == 'Jump':
                lno = int(data)
                if current_index != len(trace) - 1:
                    log.error('Must be at bottom frame')
                    continue

                try:
                    stack[current_index][0].f_lineno = lno
                except ValueError:
                    log.error('Jump failed')
                    continue

                trace[current_index]['lno'] = lno
                self.send('Trace|%s' % dump({
                    'trace': trace
                }))
                self.send('Select|%s' % dump({
                    'frame': current,
                    'breaks': self.get_file_breaks(current['file'])
                }))

            elif cmd == 'Complete':
                current_file = current['file']
                file_ = self.get_file(current_file, False).decode('utf-8')
                lines = file_.split(u'\n')
                lno = trace[current_index]['lno']
                line_before = lines[lno - 1]
                indent = len(line_before) - len(line_before.lstrip())
                segments = data.split(u'\n')
                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.complete()
                except:
                    self.send('Log|%s' % dump({
                        'message': 'Completion failed for %s' %
                        '\n'.join(reversed(segments))
                    }))
                else:
                    fun = script.get_in_function_call()
                    self.send('Suggest|%s' % dump({
                        'params': {
                            'params': [p.get_code().replace('\n', '')
                                       for p in fun.params],
                            'index': fun.index,
                            'module': fun.module.path,
                            'call_name': fun.call_name} if fun else None,
                        'completions': [{
                            'base': comp.word[
                                :len(comp.word) - len(comp.complete)],
                            'complete': comp.complete,
                            'description': comp.description
                        } for comp in completions if comp.word.endswith(
                            comp.complete)]
                    }))

            elif cmd == 'Quit':
                if hasattr(self, 'botframe'):
                    self.set_continue()
                    raise BdbQuit()
                break

            else:
                log.warn('Unknown command %s' % cmd)
开发者ID:chiehwen,项目名称:wdb,代码行数:104,代码来源:__init__.py

示例4: _interaction

# 需要导入模块: from jedi import Script [as 别名]
# 或者: from jedi.Script import get_in_function_call [as 别名]

#.........这里部分代码省略.........

                elif cmd == "Jump":
                    lno = int(data)
                    if current_index != len(trace) - 1:
                        log.error("Must be at bottom frame")
                        continue

                    try:
                        stack[current_index][0].f_lineno = lno
                    except ValueError:
                        fail()
                        continue

                    trace[current_index]["lno"] = lno
                    self.send("Trace|%s" % dump({"trace": trace}))
                    self.send("Select|%s" % dump({"frame": current, "breaks": self.get_file_breaks(current["file"])}))

                elif cmd == "Complete":
                    current_file = current["file"]
                    file_ = self.get_file(current_file, False).decode("utf-8")
                    lines = file_.split(u"\n")
                    lno = trace[current_index]["lno"]
                    line_before = lines[lno - 1]
                    indent = len(line_before) - len(line_before.lstrip())
                    segments = data.split(u"\n")
                    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.complete()
                    except:
                        log.exception("Completion failed")
                        self.send(
                            "Log|%s" % dump({"message": "Completion failed for %s" % "\n".join(reversed(segments))})
                        )
                    else:
                        fun = script.get_in_function_call()
                        self.send(
                            "Suggest|%s"
                            % dump(
                                {
                                    "params": {
                                        "params": [p.get_code().replace("\n", "") for p in fun.params],
                                        "index": fun.index,
                                        "module": fun.module.path,
                                        "call_name": fun.call_name,
                                    }
                                    if fun
                                    else None,
                                    "completions": [
                                        {
                                            "base": comp.word[: len(comp.word) - len(comp.complete)],
                                            "complete": comp.complete,
                                            "description": comp.description,
                                        }
                                        for comp in completions
                                        if comp.word.endswith(comp.complete)
                                    ],
                                }
                            )
                        )

                elif cmd == "Quit":
                    if hasattr(self, "botframe"):
                        self.set_continue()
                        raise BdbQuit()
                    break

                else:
                    log.warn("Unknown command %s" % cmd)

            except BdbQuit:
                raise
            except Exception:
                try:
                    exc = self.handle_exc()
                    type_, value = exc_info()[:2]
                    link = (
                        '<a href="https://github.com/Kozea/wdb/issues/new?'
                        'title=%s&body=%s&labels=defect" class="nogood">'
                        "Please click here to report it on Github</a>"
                    ) % (
                        quote("%s: %s" % (type_.__name__, str(value))),
                        quote("```\n%s\n```\n" % traceback.format_exc()),
                    )
                    self.send(
                        "Echo|%s" % dump({"for": escape("Error in Wdb, this is bad"), "val": exc + "<br>" + link})
                    )
                except:
                    self.send(
                        "Echo|%s"
                        % dump(
                            {
                                "for": escape("Too many errors"),
                                "val": escape("Don't really know what to say. " "Maybe it will work tomorrow."),
                            }
                        )
                    )
                    continue
开发者ID:arthru,项目名称:wdb,代码行数:104,代码来源:__init__.py

示例5: _interaction

# 需要导入模块: from jedi import Script [as 别名]
# 或者: from jedi.Script import get_in_function_call [as 别名]

#.........这里部分代码省略.........
                elif cmd == 'Unbreak':
                    lno = int(data)
                    current_file = current['file']
                    log.info('Break unset at %s:%d' % (current_file, lno))
                    self.clear_break(current_file, lno)
                    self.send('BreakUnset|%s' % dump({'lno': lno}))

                elif cmd == 'Jump':
                    lno = int(data)
                    if current_index != len(trace) - 1:
                        log.error('Must be at bottom frame')
                        continue

                    try:
                        stack[current_index][0].f_lineno = lno
                    except ValueError:
                        fail()
                        continue

                    trace[current_index]['lno'] = lno
                    self.send('Trace|%s' % dump({
                        'trace': trace
                    }))
                    self.send('Select|%s' % dump({
                        'frame': current,
                        'breaks': self.get_file_breaks(current['file'])
                    }))

                elif cmd == 'Complete':
                    current_file = current['file']
                    file_ = self.get_file(current_file, False).decode('utf-8')
                    lines = file_.split(u'\n')
                    lno = trace[current_index]['lno']
                    line_before = lines[lno - 1]
                    indent = len(line_before) - len(line_before.lstrip())
                    segments = data.split(u'\n')
                    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.complete()
                    except:
                        log.exception('Completion failed')
                        self.send('Log|%s' % dump({
                            'message': 'Completion failed for %s' %
                            '\n'.join(reversed(segments))
                        }))
                    else:
                        fun = script.get_in_function_call()
                        self.send('Suggest|%s' % dump({
                            'params': {
                                'params': [p.get_code().replace('\n', '')
                                           for p in fun.params],
                                'index': fun.index,
                                'module': fun.module.path,
                                'call_name': fun.call_name} if fun else None,
                            'completions': [{
                                'base': comp.word[
                                    :len(comp.word) - len(comp.complete)],
                                'complete': comp.complete,
                                'description': comp.description
                            } for comp in completions if comp.word.endswith(
                                comp.complete)]
                        }))

                elif cmd == 'Quit':
                    if hasattr(self, 'botframe'):
                        self.set_continue()
                        raise BdbQuit()
                    break

                else:
                    log.warn('Unknown command %s' % cmd)

            except BdbQuit:
                raise
            except Exception:
                try:
                    exc = self.handle_exc()
                    type_, value = exc_info()[:2]
                    link = ('<a href="https://github.com/Kozea/wdb/issues/new?'
                            'title=%s&body=%s&labels=defect" class="nogood">'
                            'Please click here to report it on Github</a>') % (
                                quote('%s: %s' % (type_.__name__, str(value))),
                                quote('```\n%s\n```\n' %
                                      traceback.format_exc()))
                    self.send('Echo|%s' % dump({
                        'for': escape('Error in Wdb, this is bad'),
                        'val': exc + '<br>' + link
                    }))
                except:
                    self.send('Echo|%s' % dump({
                        'for': escape('Too many errors'),
                        'val': escape("Don't really know what to say. "
                                      "Maybe it will work tomorrow.")
                    }))
                    continue
开发者ID:hellcoderz,项目名称:wdb,代码行数:104,代码来源:__init__.py


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