本文整理汇总了Python中Command.Command.get_command_func方法的典型用法代码示例。如果您正苦于以下问题:Python Command.get_command_func方法的具体用法?Python Command.get_command_func怎么用?Python Command.get_command_func使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Command.Command
的用法示例。
在下文中一共展示了Command.get_command_func方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main_loop
# 需要导入模块: from Command import Command [as 别名]
# 或者: from Command.Command import get_command_func [as 别名]
def main_loop(self):
"""The loop through the lines of the input on which it does stuff. """
input = self.file
output = self.dest
#different namespaces may be used in a later version of the tool to be
# able to easily undefine a group of macro's
namespace = namespaces.NormalNameSpace()
#this linenumber is used in error messages
self.inputLineNo = 0
#this linenumber might later be available as a macro
self.outputLineNo = 0
if self.shebang:
self.inputLineNo += 1
line = input.readLine()
for line in input:
self.inputLineNo += 1
#when a command is not found, command and after are empty strings
(before, command, after) = self.command_split(line)
#check if the text is just followed or actually processed
lc = self.last_condition()
if lc:
#only output a line when there was more than whitespace before the
# command prefix, or when the empty_line option is True.
if (before.strip() != ""
or (self.options["empty_line"] and command == "")):
output.write(self.replace_object_macro(namespace, before))
self.outputLineNo += 1
#check if the command here is to be ignored
if (command != "" and Command.command_allowed(command, lc)):
try:
Command.get_command_func(command)(namespace, after,
self.last_condition, self.conditions, self.else_found)
except ValueError as e:
self.error(e.args[0])
except IndexError as e:
self.error(e.args[0])