本文整理汇总了Python中commands.Commands.complete方法的典型用法代码示例。如果您正苦于以下问题:Python Commands.complete方法的具体用法?Python Commands.complete怎么用?Python Commands.complete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类commands.Commands
的用法示例。
在下文中一共展示了Commands.complete方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GDBMICmd
# 需要导入模块: from commands import Commands [as 别名]
# 或者: from commands.Commands import complete [as 别名]
class GDBMICmd(cmd.Cmd):
"""Simple extension of Cmd for controlling GDB."""
prompt = ""
intro = ""
def __init__(self):
"""Initialize Cmd and load the commands."""
cmd.Cmd.__init__(self)
self.use_rawinput = 1
self.completekey = "tab"
self.commands = Commands()
def do_EOF(self, line):
"""Terminate."""
return True
def dispatch_gdbmi_command_string(self, string):
"""Dispatch a GDBMI command from a string."""
command = self.resolve_gdbmi_command(string)
if command:
self.dispatch_gdbmi_command(cmd)
def dispatch_gdbmi_command(self, command):
"""Execute a GDBMI command. Should be over-ridden by children."""
print("Would invoke {0} with arguments {1} and options {2}".format(
command.command,
command.args,
command.opts))
def check_gdbmi_command(self, string):
"""Check whether a string is a valid command."""
if self.commands.complete(string):
return True
return False
def run(self):
"""Main run loop. Should be over-ridden by children if needed."""
self.cmdloop()
def resolve_gdbmi_command(self, line, err=True):
"""Parse a line into a GDBMI command."""
command = self.commands.generate_command(line)
if not command and err:
print("Bad command: " + line)
return command
def default(self, line):
"""Catch and handle all GDBMI commands."""
command = self.resolve_gdbmi_command(line)
if command:
self.dispatch_gdbmi_command(command)