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


Python Command.get_command_func方法代码示例

本文整理汇总了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])
开发者ID:Apanatshka,项目名称:C3P,代码行数:45,代码来源:Main.py


注:本文中的Command.Command.get_command_func方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。