本文整理汇总了Python中jedi.Script.completions方法的典型用法代码示例。如果您正苦于以下问题:Python Script.completions方法的具体用法?Python Script.completions怎么用?Python Script.completions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jedi.Script
的用法示例。
在下文中一共展示了Script.completions方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_loading_unicode_files_with_bad_global_charset
# 需要导入模块: from jedi import Script [as 别名]
# 或者: from jedi.Script import completions [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.completions()
示例2: do_completion
# 需要导入模块: from jedi import Script [as 别名]
# 或者: from jedi.Script import completions [as 别名]
def do_completion(self):
source = self.area.get("1.0", "end")
line = self.area.indcur()[0]
size = len(self.area.get("insert linestart", "insert"))
script = Script(source, line, size, self.area.filename)
completions = script.completions()
for ind in completions:
self.insert("end", ind.name)
示例3: feed
# 需要导入模块: from jedi import Script [as 别名]
# 或者: from jedi.Script import completions [as 别名]
def feed(self):
source = self.area.get('1.0', 'end')
line = self.area.indcur()[0]
size = len(self.area.get('insert linestart', 'insert'))
script = Script(source, line, size, self.area.filename)
completions = script.completions()
for ind in completions:
self.box.insert('end', ind.name)
示例4: __init__
# 需要导入模块: from jedi import Script [as 别名]
# 或者: from jedi.Script import completions [as 别名]
def __init__(self, area, *args, **kwargs):
CompleteBox.__init__(self, area, *args, **kwargs)
source = self.area.get('1.0', 'end')
line = self.area.indcur()[0]
size = len(self.area.get('insert linestart', 'insert'))
script = Script(source, line, size, self.area.filename)
completions = script.completions()
for ind in completions:
self.insert('end', ind.name)
示例5: do_complete
# 需要导入模块: from jedi import Script [as 别名]
# 或者: from jedi.Script import completions [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))))