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


Python Element.attributes['type']方法代码示例

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


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

示例1: showHelpAction

# 需要导入模块: from twisted.words.xish.domish import Element [as 别名]
# 或者: from twisted.words.xish.domish.Element import attributes['type'] [as 别名]
	def showHelpAction(self, el, sessionid=None):
		to = el.getAttribute('from')
		ID = el.getAttribute('id')
		ulang = utils.getLang(el)
		
		iq = Element((None, 'iq'))
		iq.attributes['to'] = to
		iq.attributes['from'] = config.jid
		if ID:
			iq.attributes['id'] = ID
		iq.attributes['type'] = 'result'
		
		command = iq.addElement('command')
		if sessionid:
			command.attributes['sessionid'] = sessionid
		else:
			command.attributes['sessionid'] = self.pytrans.makeMessageID()
		command.attributes['node'] = 'help'
		command.attributes['xmlns'] = globals.COMMANDS
		command.attributes['status'] = 'executing'
		
		actions = command.addElement('actions')
		actions.attributes['execute'] = 'next'
		actions.addElement('next')

		x = command.addElement('x')
		x.attributes['xmlns'] = 'jabber:x:data'
		x.attributes['type'] = 'form'

		title = x.addElement('title')
		title.addContent(lang.get('command_Help'))
		
		instructions = x.addElement('instructions')
		instructions.addContent(lang.get('help_documentation'))
		
		field = x.addElement('field')
		field.attributes['var'] = 'help_action'
		field.attributes['type'] = 'list-single'
		field.attributes['label'] = lang.get('help_action')
		desc = field.addElement('desc')
		desc.addContent(lang.get('help_action_Desc'))
		
		option = field.addElement('option')
		option.attributes['label'] = help_mainroom
		value = option.addElement('value')
		value.addContent(help_mainroom)
		
		if config.supportRoom:
			option = field.addElement('option')
			option.attributes['label'] = config.supportRoom
			value = option.addElement('value')
			value.addContent(config.supportRoom)
			
		stage = x.addElement('field')
		stage.attributes['type'] = 'hidden'
		stage.attributes['var'] = 'stage'
		value = stage.addElement('value')
		value.addContent('2')
		
		self.pytrans.send(iq)
开发者ID:anton-ryzhov,项目名称:pyicqt_auto_reconnect,代码行数:62,代码来源:Help.py

示例2: sendPresence

# 需要导入模块: from twisted.words.xish.domish import Element [as 别名]
# 或者: from twisted.words.xish.domish.Element import attributes['type'] [as 别名]
	def sendPresence(self, destination: JID, presenceType: str, status: str = None, show: str = None,
					 priority: int = None, source: JID = None, nick: str = None):
		if not source:
			source = JID(self.config.JID)
		presence = Element((None, 'presence'))
		presence.attributes['to'] = destination.userhost()
		presence.attributes['from'] = source.userhost()
		presence.attributes['type'] = presenceType
		if status:
			presence.addElement('status').addContent(status)
		if show:
			presence.addElement('show').addContent(show)
		if priority:
			presence.addElement('priority').addContent(priority)
		if nick:
			nickElement = presence.addElement('nick', content=nick)
			nickElement.attributes["xmlns"] = "http://jabber.org/protocol/nick"
		print("PresenceSend: " + source.full() + " -> " + destination.full() + " : " + presenceType)
		self.send(presence)
开发者ID:vladamatena,项目名称:h2x,代码行数:21,代码来源:h2x.py

示例3: sendXStatusCompleted

# 需要导入模块: from twisted.words.xish.domish import Element [as 别名]
# 或者: from twisted.words.xish.domish.Element import attributes['type'] [as 别名]
	def sendXStatusCompleted(self, el, message, sessionid=None):
		to = el.getAttribute('from')
		ID = el.getAttribute('id')
		ulang = utils.getLang(el)
		
		iq = Element((None, 'iq'))
		iq.attributes['to'] = to
		iq.attributes['from'] = config.jid
		if ID:
			iq.attributes['id'] = ID
		iq.attributes['type'] = 'result'
		
		command = iq.addElement('command')
		if sessionid:
			command.attributes['sessionid'] = sessionid
		else:
			command.attributes['sessionid'] = self.pytrans.makeMessageID()
		command.attributes['node'] = 'setxstatus'
		command.attributes['xmlns'] = globals.COMMANDS
		command.attributes['status'] = 'completed'
		
		note = command.addElement('note')
		note.attributes['type'] = 'info'
		note.addContent(message)
		
		x = command.addElement('x')
		x.attributes['xmlns'] = 'jabber:x:data'
		x.attributes['type'] = 'form'

		title = x.addElement('title')
		title.addContent(lang.get('command_SetXStatus'))
		
		instructions = x.addElement('instructions')
		instructions.addContent(message)
		
		self.pytrans.send(iq)
开发者ID:anton-ryzhov,项目名称:pyicqt_auto_reconnect,代码行数:38,代码来源:SetXStatus.py

示例4: sendXStatusNameSelectionForm

# 需要导入模块: from twisted.words.xish.domish import Element [as 别名]
# 或者: from twisted.words.xish.domish.Element import attributes['type'] [as 别名]
	def sendXStatusNameSelectionForm(self, el, sessionid=None):
		to = el.getAttribute('from')
		to_jid = internJID(to)
		jid = to_jid.userhost()
		ID = el.getAttribute('id')
		ulang = utils.getLang(el)
		
		iq = Element((None, 'iq'))
		iq.attributes['to'] = to
		iq.attributes['from'] = config.jid
		if ID:
			iq.attributes['id'] = ID
		iq.attributes['type'] = 'result'
		
		command = iq.addElement('command')
		if sessionid:
			command.attributes['sessionid'] = sessionid
		else:
			command.attributes['sessionid'] = self.pytrans.makeMessageID()
		command.attributes['node'] = 'setxstatus'
		command.attributes['xmlns'] = globals.COMMANDS
		command.attributes['status'] = 'executing'
		
		actions = command.addElement('actions')
		actions.attributes['execute'] = 'next'
		actions.addElement('next')

		x = command.addElement('x')
		x.attributes['xmlns'] = 'jabber:x:data'
		x.attributes['type'] = 'form'

		title = x.addElement('title')
		title.addContent(lang.get('xstatus_set_xstatus_name'))
		
		instructions = x.addElement('instructions')
		instructions.addContent(lang.get('xstatus_set_instructions'))
		
		field = x.addElement('field')
		field.attributes['var'] = 'xstatus_name'
		field.attributes['type'] =  'list-single'
		field.attributes['label'] = lang.get('xstatus_name')
		desc = field.addElement('desc')
		desc.addContent(lang.get('xstatus_set_instructions_Desc'))
		
		option = field.addElement('option')
		option.attributes['label'] = lang.get('xstatus_no_xstatus')
		value = option.addElement('value')
		value.addContent('None')
		
		counter = 0
		limit = False
		if int(self.pytrans.sessions[jid].legacycon.bos.settingsOptionValue('xstatus_sending_mode')) == 2:
			limit = True
			counter = 24
		for xstatus_title in oscar.X_STATUS_NAME:
			if limit:
				if counter > 0:
					option = field.addElement('option')
					option.attributes['label'] = lang.get(xstatus_title)
					value = option.addElement('value')
					value.addContent(xstatus_title)
					counter -= 1
			else:
				option = field.addElement('option')
				option.attributes['label'] = lang.get(xstatus_title)
				value = option.addElement('value')
				value.addContent(xstatus_title)
			
		value = field.addElement('value')
		current_xstatus_name = self.pytrans.sessions[jid].legacycon.bos.getSelfXstatusName()
		if current_xstatus_name != '':
			value.addContent(current_xstatus_name)
		else:
			value.addContent('None')
			
		stage = x.addElement('field')
		stage.attributes['type'] = 'hidden'
		stage.attributes['var'] = 'stage'
		value = stage.addElement('value')
		value.addContent('1')

		self.pytrans.send(iq)
开发者ID:anton-ryzhov,项目名称:pyicqt_auto_reconnect,代码行数:84,代码来源:SetXStatus.py

示例5: sendXStatusTextSelectionForm

# 需要导入模块: from twisted.words.xish.domish import Element [as 别名]
# 或者: from twisted.words.xish.domish.Element import attributes['type'] [as 别名]
	def sendXStatusTextSelectionForm(self, el, xstatus_name, sessionid=None):

		to = el.getAttribute('from')
		ID = el.getAttribute('id')
		ulang = utils.getLang(el)
		
		iq = Element((None, 'iq'))
		iq.attributes['to'] = to
		iq.attributes['from'] = config.jid
		if ID:
			iq.attributes['id'] = ID
		iq.attributes['type'] = 'result' 
		
		command = iq.addElement('command')
		if sessionid:
			command.attributes['sessionid'] = sessionid
		else:
			command.attributes['sessionid'] = self.pytrans.makeMessageID()
		command.attributes['node'] = 'setxstatus'
		command.attributes['xmlns'] = globals.COMMANDS
		command.attributes['status'] = 'executing'
		
		actions = command.addElement('actions')
		actions.attributes['execute'] = 'complete'
		actions.addElement('prev')
		actions.addElement('complete')

		x = command.addElement('x')
		x.attributes['xmlns'] = 'jabber:x:data'
		x.attributes['type'] = 'form'

		title = x.addElement('title')
		title.addContent(lang.get('xstatus_set_details'))	
			
		toj = internJID(to)
		jid = toj.userhost()
		xstatus_number = self.pytrans.sessions[jid].legacycon.bos.getXstatusNumberByName(xstatus_name)
		title, desc = self.pytrans.xdb.getXstatusText(jid, xstatus_number)
		if title == '':
			title = lang.get(xstatus_name)
		else:
			if config.xdbDriver == 'xmlfiles': # fix problem with & character
				title = utils.fixCharactersInDeXML(title)	
			
		xstatus_title = x.addElement('field')
		xstatus_title.attributes['type'] = 'text-single'
		xstatus_title.attributes['var'] = 'xstatus_title'
		xstatus_title.attributes['label'] = lang.get('xstatus_title')
		value = xstatus_title.addElement('value')
		value.addContent(title)
		
		xstatus_desc = x.addElement('field')
		xstatus_desc.attributes['type'] = 'text-multi'
		xstatus_desc.attributes['var'] = 'xstatus_desc'
		xstatus_desc.attributes['label'] = lang.get('xstatus_description')
		value = xstatus_desc.addElement('value')
		value.addContent(desc)
		
		xstatus_icon = x.addElement('field')
		xstatus_icon.attributes['type'] = 'hidden'
		xstatus_icon.attributes['var'] = 'xstatus_name'
		value = xstatus_icon.addElement('value')
		value.addContent(xstatus_name)
		
		stage = x.addElement('field')
		stage.attributes['type'] = 'hidden'
		stage.attributes['var'] = 'stage'
		value = stage.addElement('value')
		value.addContent('2')
		
		self.pytrans.send(iq)
开发者ID:anton-ryzhov,项目名称:pyicqt_auto_reconnect,代码行数:73,代码来源:SetXStatus.py


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