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


Python Node.del_attributes方法代码示例

本文整理汇总了Python中magpieparsers.parser_common.Node.del_attributes方法的典型用法代码示例。如果您正苦于以下问题:Python Node.del_attributes方法的具体用法?Python Node.del_attributes怎么用?Python Node.del_attributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在magpieparsers.parser_common.Node的用法示例。


在下文中一共展示了Node.del_attributes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: interf

# 需要导入模块: from magpieparsers.parser_common import Node [as 别名]
# 或者: from magpieparsers.parser_common.Node import del_attributes [as 别名]
	def interf(self,ast,  pt, decorators):
		# ... create the type
		interface = Node(ast, 'type', source = pt)
		interface.add_attribute('meta_type', 'interface')
		# ... add modifiers
		if pt.leaf == 'abstract' or pt.leaf == 'local':
			interface.add_attribute('modifier', pt.leaf)
		# ... set interface name
		interface.leaf = pt.the('identifier').leaf

		# If the interface already exists in incomplete form, use that instead.
		old_interfaces = infogripper.getAllNodes(interface.leaf, ast, 'type')
		if old_interfaces:
			# Found a previous declaration; use that.
			assert len(old_interfaces) == 1
			interface = old_interfaces[0]
		else:
			# Okay, it doesn't exist already: add it.
			ast.add_child(interface)

		# While we're building it, add the "incomplete" attribute.
		interface.add_attribute('incomplete', True)
		is_incomplete = True
		for child in pt.children:
			if child.type == 'interface_dcl':
				is_incomplete = False
				#print child
				if child.the('interface_header') != None:
					scope_list = child.the('interface_header').the('interface_inheritance_spec').the('scoped_name_list')
					for scope_name in scope_list['scoped_name']:
						inher_node = Node(interface, 'inherits', leaf = self.scoped_name(scope_name), source = child)
						inher_node.add_child(infogripper.find_scope(interface, inher_node.leaf))

						# Ensure we're not inheriting from the same class twice.
						self.check_not_inherited(interface, inher_node.children[0], error_infonode = scope_name)
						interface.add_child(inher_node)
						
						
				if child.the('interface_body') != None:
					for export_child in child.the('interface_body').children:
						self.export(interface, export_child)

		# Remove "incomplete" if the interface was fully-defined above.
		if not is_incomplete:
			interface.del_attributes('incomplete')

		interface.add_children(decorators)

		self._dupes_check(interface)
开发者ID:BruceYi,项目名称:okl4,代码行数:51,代码来源:astgen.py


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