예제 #1
0
def editEntry(entry, entryId):
	'''Modifies an entry in the xml.'''
	global menu
	element = idIndex['menu'][entryId]
	locale = entry[entry.keys()[0]]['name'].keys()[0]
	name = element.getElementsByTagName('name')[0].getElementsByTagName(locale)[0].firstChild.nodeValue
	new_name = entry[entry.keys()[0]]['name'][locale]
	if not name == new_name:
		element.getElementsByTagName('name')[0].getElementsByTagName(locale)[0].firstChild.nodeValue = new_name
	command = element.getElementsByTagName('command')[0].firstChild.nodeValue
	new_command = entry[entry.keys()[0]]['command']
	if not command == new_command:
		element.getElementsByTagName('command')[0].firstChild.nodeValue = new_command
		
	try:
		new_icon = entry[entry.keys()[0]]['icon']['file']
		if len(element.getElementsByTagName('icon')) > 0:
			try:
				icon = element.getElementsByTagName('icon')[0].getElementsByTagName('file')[0].firstChild.nodeValue
				if not icon == new_icon:
					element.getElementsByTagName('icon')[0].getElementsByTagName('file')[0].firstChild.nodeValue = new_icon
			except:
				denu_shared.buildDOM(entry[entry.keys()[0]]['icon'], element.getElementsByTagName('icon')[0], menu)
		else:
			denu_shared.buildDOM({'icon': {'file': new_icon}}, element, menu)
	except:
		pass
	return "Successful."
예제 #2
0
	def endElement(self, name):
		if not name == "data":
			self.location.pop()
		if name == "program" and self.keep == 1:
			if self.location_parent.has_key(self.entry['program']['location']):
				prgm_parent = self.location_parent[self.entry['program']['location']]
			else:
				prgm_parent = self.location_parent['|Lost']
			denu_shared.buildDOM(self.entry, prgm_parent, self.dom)
예제 #3
0
def addEntry(entry, parent, sibling=None):
	'''Inserts an entry into the denu xml structure.'''
	global idIndex
	global menu
	newId = []
	for key in entry.keys():
		tmp = menu.createElement(key)
		denu_shared.buildDOM(entry[key], tmp, menu)
		if sibling == None:
			idIndex['menu'][parent].appendChild(tmp)
		else:
			idIndex['menu'][parent].insertBefore(tmp, idIndex['menu'][sibling])
		tmpId = len(idIndex['menu'])/2
		newId.append(tmpId)
		idIndex['menu'][tmpId] = tmp
		idIndex['menu'][tmp] = tmpId
	return newId