本文整理汇总了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()
示例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)]
}))
示例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)
示例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
示例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