예제 #1
0
	def __init__(self, param=None, *args, **kwargs):
		'''
		Class constructor that builds the manually
		the XML of the stanza. This procedure is needed
		at the moment to be able to include text into
		the stanza root elements, as the default 
		functionality does not seem to allow that. 
		After defining the XML body of the stanza, 
		ElementBase is initiated passing the body of the
		stanza as an argument for the `xml` parameter
		of the ElementBase class. 
		'''
		ET.register_namespace('', 'intamac:intamacdeviceinfo')
		root = ET.Element('{intamac:intamacdeviceinfo}intamacdeviceinfo')
		root.text = param
		ElementBase.__init__(self, xml=root)
예제 #2
0
	def __init__(self, 
				soundpacklist=False, 
				tag=None, 
				enabled=None, 
				sensitivity=None, 
				type=None, 
				url=None, 
				param='', 
				*args, 
				**kwargs):
		'''
		Class constructor that builds the manually
		the XML of the stanza. This procedure is needed
		at the moment to be able to include text into
		the stanza root elements, as the default 
		functionality does not seem to allow that. 
		After defining the XML body of the stanza, 
		ElementBase is initiated passing the body of the
		stanza as an argument for the `xml` parameter
		of the ElementBase class. 
		'''
		# Do we want to make checks on the values passed as parameters for each of
		# these tags? For example, do we want to ensure that enabled is only True
		# or False, or that tag is only one of Aggression, BabyCry, CarAlarm, etc.? 
		ET.register_namespace('', 'intamac:intamacapi')
		root = ET.Element('{intamac:intamacapi}intamacapi')
		root.text = param
		if soundpacklist == True:
			sound_pack_list = ET.SubElement(root, 'SoundPackList')
			sound_pack = ET.SubElement(sound_pack_list, 'SoundPack')
			tag_tag = ET.SubElement(sound_pack, 'tag')
			tag_tag.text = tag
			tag_enabled = ET.SubElement(sound_pack, 'enabled')
			tag_enabled.text = enabled
			tag_sensitivity = ET.SubElement(sound_pack, 'sensitivity')
			tag_sensitivity.text = sensitivity
		ElementBase.__init__(self, xml=root)
		self['type'] = type
		self['url'] = url