コード例 #1
0
ファイル: pointcontainer.py プロジェクト: gic888/MIEN
	def __init__(self, node, container=None):
		''' adds "Point" subelements to self, and removes them from node.
Creates the array self.points and the hash self.point_labels'''
		if node.has_key('point_data'):
			self.points, self.point_labels =node['point_data']
			del(node['point_data'])
			NmpmlObject.__init__(self, node, container)
		else:	
			NmpmlObject.__init__(self, node, container)
			pnodes=[d for d in node['elements'] if d['tag']=="Point"]
			for n in pnodes:
				node['elements'].remove(n)	
			self.points, self.point_labels=treeToPoints(pnodes)
コード例 #2
0
ファイル: section.py プロジェクト: gic888/MIEN
	def setName(self, name=None):
		'''always ues this function to change the name of an nmpml 
object, to avoid generating non-unique names.
If this function is called without arguments (or name is None), it will
verify name uniqueness of the current name.

Return value is the actual name that was set (which may be different than
the provided argument do to required name uniqueness)

Its a very good idea to call "update_refs" after calling this function, 
since it may break references
'''
		on=self.attributes['Name']
		name=NmpmlObject.setName(self, name)
		cell=self.container
		if name==on and cell._sections.get(name)==self:
			return
		if cell._sections.has_key(on):
			del(cell._sections[on])
		cell._sections[name]=self		
		p = self.parent()
		if cell._children.has_key(p):
			if on in cell._children[p]:
				cell._children[p].remove(on)
			cell._children[p].add(name)
		else:
			cell._children[p]=set([name])
		if  cell._children.has_key(on):
			for c in cell._children[on]:
				c=cell._sections[c]
				c.attributes['Parent']=name
			cell._children[name]=cell._children[on]	
			del(cell._children[on])
コード例 #3
0
ファイル: gicdat.py プロジェクト: gic888/MIEN
def make_nested(secs):
	root =None
	new={}
	for s in secs:
		ns=NmpmlObject({'tag':"Cell", 'attributes':s.attributes, 'elements':[], 'cdata':None})
		ns.data = s.getPoints()
		for e in s.elements:
			ns.newElement(e)
		if not s.parent():
			root = ns
		new[s.name()]=ns	
	for name in new:
		s = new[name]
		if s == root:
			continue
		p = s.attrib("Parent")
		del(s.attributes["Parent"])
		s.move(new[p])
	return root
コード例 #4
0
ファイル: density.py プロジェクト: gic888/MIEN
	def setAttrib(self, a, v, inherit=False):
		'''set attributes key a to v, with cast to python datatypes'''
		NmpmlObject.setAttrib(self, a, v, inherit)
		if a in ["Origin", "Edge"]:
			d=self.getElements("Data")
			d[0].setAttrib(a, v)
コード例 #5
0
ファイル: evalserver.py プロジェクト: gic888/MIEN
	def __init__(self, node, container=None):
		NmpmlObject.__init__(self, node, container)
		self.server=None
コード例 #6
0
ファイル: walker.py プロジェクト: gic888/mienblocks
	def __init__(self, node, container=None):
		NmpmlObject.__init__(self, node, container)
		Walker.__init__(self)