當前位置: 首頁>>代碼示例>>Python>>正文


Python Command.command_allowed方法代碼示例

本文整理匯總了Python中Command.Command.command_allowed方法的典型用法代碼示例。如果您正苦於以下問題:Python Command.command_allowed方法的具體用法?Python Command.command_allowed怎麽用?Python Command.command_allowed使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Command.Command的用法示例。


在下文中一共展示了Command.command_allowed方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: main_loop

# 需要導入模塊: from Command import Command [as 別名]
# 或者: from Command.Command import command_allowed [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.command_allowed方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。