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


Python Script.complete方法代码示例

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


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

示例1: test_loading_unicode_files_with_bad_global_charset

# 需要导入模块: from jedi import Script [as 别名]
# 或者: from jedi.Script import complete [as 别名]
def test_loading_unicode_files_with_bad_global_charset(monkeypatch, tmpdir):
    dirname = str(tmpdir.mkdir('jedi-test'))
    filename1 = os.path.join(dirname, 'test1.py')
    filename2 = os.path.join(dirname, 'test2.py')
    if sys.version_info < (3, 0):
        data = "# coding: latin-1\nfoo = 'm\xf6p'\n"
    else:
        data = "# coding: latin-1\nfoo = 'm\xf6p'\n".encode("latin-1")

    with open(filename1, "wb") as f:
        f.write(data)
    s = Script("from test1 import foo\nfoo.",
               line=2, column=4, path=filename2)
    s.complete()
开发者ID:Hylen,项目名称:jedi,代码行数:16,代码来源:test_regression.py

示例2: ComputeCandidates

# 需要导入模块: from jedi import Script [as 别名]
# 或者: from jedi.Script import complete [as 别名]
  def ComputeCandidates( self, unused_query, unused_start_column ):
    filename = vim.current.buffer.name
    line, column = vimsupport.CurrentLineAndColumn()
    # Jedi expects lines to start at 1, not 0
    line += 1
    contents = '\n'.join( vim.current.buffer )
    script = Script( contents, line, column, filename )

    return [ { 'word': str( completion.word ),
               'menu': str( completion.description ),
               'info': str( completion.doc ) }
             for completion in script.complete() ]
开发者ID:arcarson,项目名称:dotfiles,代码行数:14,代码来源:jedi_completer.py

示例3: SetCandidates

# 需要导入模块: from jedi import Script [as 别名]
# 或者: from jedi.Script import complete [as 别名]
  def SetCandidates( self ):
    while True:
      try:
        WaitAndClear( self._query_ready )

        filename = vim.current.buffer.name
        line, column = vimsupport.CurrentLineAndColumn()
        # Jedi expects lines to start at 1, not 0
        line += 1
        contents = '\n'.join( vim.current.buffer )
        script = Script( contents, line, column, filename )

        self._candidates = [ { 'word': str( completion.word ),
                               'menu': str( completion.description ),
                               'info': str( completion.doc ) }
                            for completion in script.complete() ]
      except:
        self._query_ready.clear()
        self._candidates = []
      self._candidates_ready.set()
开发者ID:Lichtlos,项目名称:YouCompleteMe,代码行数:22,代码来源:jedi_completer.py

示例4: do_complete

# 需要导入模块: from jedi import Script [as 别名]
# 或者: from jedi.Script import complete [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

示例5: update

# 需要导入模块: from jedi import Script [as 别名]
# 或者: from jedi.Script import complete [as 别名]
 def update(self, source_code, line, col, filename, encoding):
     # complete with jedi
     try:
         script = Script(source_code, line, col, filename, encoding)
         completions = script.complete()
         # clean suggestion list
         self._suggestions[:] = []
         for completion in completions:
             # get type from description
             desc = completion.description
             suggestionType = desc.split(":")[0]
             # get the associated icon if any
             icon = None
             if suggestionType in Icons:
                 icon = Icons[suggestionType]
             else:
                 print "PCEF WARNING: Unimplemented suggestion type: %s" % suggestionType
             # add the suggestion to the list
             self._suggestions.append(Suggestion(completion.word, icon=icon, description=desc.split(":")[1]))
     except:
         pass
开发者ID:hofoen,项目名称:pcef-core,代码行数:23,代码来源:py_cc.py

示例6: _interaction

# 需要导入模块: from jedi import Script [as 别名]
# 或者: from jedi.Script import complete [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

示例7: _interaction

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

#.........这里部分代码省略.........
                    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)
                                    ],
                                }
                            )
                        )
开发者ID:arthru,项目名称:wdb,代码行数:69,代码来源:__init__.py

示例8: _interaction

# 需要导入模块: from jedi import Script [as 别名]
# 或者: from jedi.Script import complete [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.complete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。