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


Python Element.attributes["id"]方法代码示例

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


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

示例1: sendMessage

# 需要导入模块: from twisted.words.xish.domish import Element [as 别名]
# 或者: from twisted.words.xish.domish.Element import attributes["id"] [as 别名]
def sendMessage(pytrans, to, fro, body=None, mtype=None, delay=None,
                xhtml=None, nickname=None, receipt=None, mID=None):
    """ Sends a Jabber message """
    LogEvent(INFO)
    el = Element((None, "message"))
    el.attributes["to"] = to
    el.attributes["from"] = fro
    if mID:
        el.attributes["id"] = mID
    else:
        el.attributes["id"] = pytrans.makeMessageID()
    if mtype:
        el.attributes["type"] = mtype

    if delay:
        x = el.addElement("x")
        x.attributes["xmlns"] = globals.XDELAY
        x.attributes["from"] = fro
        x.attributes["stamp"] = delay

    if nickname:
        n = el.addElement("nick")
        n.attributes["xmlns"] = globals.NICK
        n.addContent(nickname)

    if receipt:
        r = el.addElement("received")
        r.attributes["xmlns"] = globals.RECEIPTS
    else:  # do not send state info in message receipt
        x = el.addElement("x")
        x.attributes["xmlns"] = globals.XEVENT
        composing = x.addElement("composing")
        xx = el.addElement("active")
        xx.attributes["xmlns"] = globals.CHATSTATES

    if body:
        b = el.addElement("body")
        b.addContent(utils.xmlify(body))

    if xhtml and not config.disableXHTML:
        try:
            el.addChild(utils.parseText(xhtml))
        except:
            # Hrm, didn't add, we're not going to end the world
            # because of it.
            pass

    pytrans.send(el)
    sendArchive(pytrans, to, fro, body)
开发者ID:2mf,项目名称:pyicqt,代码行数:51,代码来源:jabw.py

示例2: __getDiscoInfo

# 需要导入模块: from twisted.words.xish.domish import Element [as 别名]
# 或者: from twisted.words.xish.domish.Element import attributes["id"] [as 别名]
    def __getDiscoInfo(self, sender: JID, identifier: str, node: str):
        iq = Element((None, "iq"))
        iq.attributes["type"] = "result"
        iq.attributes["from"] = self.h2x.config.JID
        iq.attributes["to"] = sender.full()
        if identifier:
            iq.attributes["id"] = identifier
        query = iq.addElement("query")
        query.attributes["xmlns"] = "http://jabber.org/protocol/disco#info"

        # Node not set -> send component identity
        if node == None:
            identity = query.addElement("identity")
            identity.attributes["name"] = "Google Hangouts transport"
            identity.attributes["category"] = "gateway"
            identity.attributes["type"] = "XMPP"
            query.addElement("feature").attributes["var"] = "jabber:iq:gateway"
            query.addElement("feature").attributes["var"] = "jabber:iq:register"
            query.addElement("feature").attributes["var"] = "jabber:iq:version"

            # Generic features for both node and component
        query.addElement("feature").attributes["var"] = "http://jabber.org/protocol/commands"
        query.addElement("feature").attributes["var"] = "http://jabber.org/protocol/disco#items"
        query.addElement("feature").attributes["var"] = "http://jabber.org/protocol/disco#info"

        self.h2x.send(iq)
开发者ID:vladamatena,项目名称:h2x,代码行数:28,代码来源:iq.py

示例3: send

# 需要导入模块: from twisted.words.xish.domish import Element [as 别名]
# 或者: from twisted.words.xish.domish.Element import attributes["id"] [as 别名]
    def send(self, to, body, subject=None, mtype=None, delay=None):
        print 'start sending'
        el = Element((None, "message"))
        el.attributes["to"] = to
        el.attributes["from"] = self.juser
        el.attributes["id"] = '111111'
        
        if(subject):
            subj = el.addElement("subject")
            subj.addContent(subject)
        
        if(mtype):
            el.attributes["type"] = mtype
        
        if(delay):
            x = el.addElement("x")
            x.attributes["xmlns"] = "jabber:x:delay"
            x.attributes["from"] = fro
            x.attributes["stamp"] = delay
        
        b = el.addElement("body")
        b.addContent(body)
              
        
        
        self.theXmlstream.send(el)    

        print 'done sending'
开发者ID:CuonDeveloper,项目名称:cuon,代码行数:30,代码来源:xmpp_client.py

示例4: pwdChangeResults

# 需要导入模块: from twisted.words.xish.domish import Element [as 别名]
# 或者: from twisted.words.xish.domish.Element import attributes["id"] [as 别名]
	def pwdChangeResults(self, results, el, sessionid, newpassword):
		to = el.getAttribute("from")
		toj = internJID(to)
		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"] = "changepassword"
		command.attributes["xmlns"] = globals.COMMANDS
		command.attributes["status"] = "completed"

		note = command.addElement("note")
		if results[3]:
			note.attributes["type"] = "error"
			note.addContent(lang.get("command_ChangePassword_Failed", ulang))
		else:
			note.attributes["type"] = "info"
			note.addContent(lang.get("command_Done", ulang))
			(username, oldpassword) = self.pytrans.xdb.getRegistration(toj.userhost())
			self.pytrans.xdb.setRegistration(toj.userhost(), username, newpassword)

		self.pytrans.send(iq)
开发者ID:Ashaman-,项目名称:pyaimt,代码行数:35,代码来源:ChangePassword.py

示例5: sendError

# 需要导入模块: from twisted.words.xish.domish import Element [as 别名]
# 或者: from twisted.words.xish.domish.Element import attributes["id"] [as 别名]
	def sendError(self, node, el, errormsg, 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"] = node
		command.attributes["xmlns"] = globals.COMMANDS
		command.attributes["status"] = "completed"

		note = command.addElement("note")
		note.attributes["type"] = "error"
		note.addContent(errormsg)

		self.pytrans.send(iq)
开发者ID:Ashaman-,项目名称:pyaimt,代码行数:28,代码来源:adhoc.py

示例6: sendDiscoItemsResponse

# 需要导入模块: from twisted.words.xish.domish import Element [as 别名]
# 或者: from twisted.words.xish.domish.Element import attributes["id"] [as 别名]
	def sendDiscoItemsResponse(self, to, ID, ulang, jid):
		""" Send a service discovery disco#items stanza to the given 'to'. 'jid' is the JID that was queried. """
		LogEvent(INFO)
		iq = Element((None, "iq"))
		iq.attributes["type"] = "result"
		iq.attributes["from"] = jid
		iq.attributes["to"] = to
		if ID:
			iq.attributes["id"] = ID
		query = iq.addElement("query")
		query.attributes["xmlns"] = globals.DISCO_ITEMS

		searchjid = jid
		if jid.find('@') > 0: searchjid = "USER"

		for node in self.nodes.get(searchjid, []):
			handler, name, rootnode = self.nodes[jid][node]
			if rootnode:
				LogEvent(INFO, msg="Found node %r" % (node))
				name = lang.get(name, ulang)
				item = query.addElement("item")
				item.attributes["jid"] = jid
				item.attributes["node"] = node
				item.attributes["name"] = name

		if searchjid == "USER":
			# Add any user specific items
			for hndl in self.userItemHandlers:
				hndl(jid, query)
		
		self.pytrans.send(iq)
开发者ID:Ashaman-,项目名称:pyaimt,代码行数:33,代码来源:disco.py

示例7: sendMood

# 需要导入模块: from twisted.words.xish.domish import Element [as 别名]
# 或者: from twisted.words.xish.domish.Element import attributes["id"] [as 别名]
	def sendMood(self, to=None, fro=None, mood=None, text=None, action=None):
		"""
		send mood to user
		"""
		LogEvent(INFO)
		el = Element((None, "message"))
		el.attributes["id"] = self.pytrans.makeMessageID()
		if fro:
			el.attributes["from"] = fro
	
		e = el.addElement("event")
		e.attributes["xmlns"] = globals.PUBSUBEVENT
		
		items = e.addElement("items")
		items.attributes["node"] = globals.MOOD
		
		if action == 'retract':
			r = items.addElement("retract")
			r.attributes["id"] = self.pytrans.makeMessageID()
		else:
			item = items.addElement("item")
			item.attributes["id"] = self.pytrans.makeMessageID()
			
			m = item.addElement("mood")
			m.attributes["xmlns"] = globals.MOOD
			
			if mood:
				m.addElement(mood)
			if text:
				t = m.addElement("text")
				t.addContent(text)

		for res in self.pytrans.sessions[to].resourceList: # send to every resource
			el.attributes["to"] = to + '/' + res
			self.pytrans.send(el)
开发者ID:anton-ryzhov,项目名称:pyicqt_auto_reconnect,代码行数:37,代码来源:pubsub.py

示例8: sendResponse

# 需要导入模块: from twisted.words.xish.domish import Element [as 别名]
# 或者: from twisted.words.xish.domish.Element import attributes["id"] [as 别名]
	def sendResponse(self, failure, el, sessionid=None):
		LogEvent(INFO)
		to = el.getAttribute("from")
		toj = internJID(to)
		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"] = "confirmaccount"
		command.attributes["xmlns"] = globals.COMMANDS
		command.attributes["status"] = "completed"

		note = command.addElement("note")
		if failure:
			note.attributes["type"] = "error"
			note.addContent(lang.get("command_ConfirmAccount_Failed", ulang))
		else:
			note.attributes["type"] = "info"
			note.addContent(lang.get("command_ConfirmAccount_Complete", ulang))

		self.pytrans.send(iq)
开发者ID:Ashaman-,项目名称:pyaimt,代码行数:34,代码来源:ConfirmAccount.py

示例9: sendCommandInfoResponse

# 需要导入模块: from twisted.words.xish.domish import Element [as 别名]
# 或者: from twisted.words.xish.domish.Element import attributes["id"] [as 别名]
	def sendCommandInfoResponse(self, to, ID, node, ulang):
		LogEvent(INFO, msg="Replying to disco#info")
		iq = Element((None, "iq"))
		iq.attributes["type"] = "result"
		iq.attributes["from"] = config.jid
		iq.attributes["to"] = to
		if ID: iq.attributes["id"] = ID
		query = iq.addElement("query")
		query.attributes["xmlns"] = globals.DISCO_INFO

		# Add identity
		identity = query.addElement("identity")
		identity.attributes["name"] = lang.get(self.commandNames[node], ulang)
		identity.attributes["category"] = "automation"
		identity.attributes["type"] = "command-node"

		# Add supported feature
		feature = query.addElement("feature")
		feature.attributes["var"] = globals.COMMANDS

		# Add supported feature
		feature = query.addElement("feature")
		feature.attributes["var"] = globals.XDATA

		self.pytrans.send(iq)
开发者ID:Ashaman-,项目名称:pyaimt,代码行数:27,代码来源:adhoc.py

示例10: sendRegistrationFields

# 需要导入模块: from twisted.words.xish.domish import Element [as 别名]
# 或者: from twisted.words.xish.domish.Element import attributes["id"] [as 别名]
    def sendRegistrationFields(self, incoming):
        # Construct a reply with the fields they must fill out
        LogEvent(INFO)
        reply = Element((None, "iq"))
        reply.attributes["from"] = config.jid
        reply.attributes["to"] = incoming.getAttribute("from")
        reply.attributes["id"] = incoming.getAttribute("id")
        reply.attributes["type"] = "result"
        query = reply.addElement("query")
        query.attributes["xmlns"] = globals.IQREGISTER
        instructions = query.addElement("instructions")
        ulang = utils.getLang(incoming)
        instructions.addContent(lang.get("registertext", ulang))
        userEl = query.addElement("username")
        passEl = query.addElement("password")

        # Check to see if they're registered
        source = internJID(incoming.getAttribute("from")).userhost()
        result = self.pytrans.xdb.getRegistration(source)
        if result:
            username, password = result
            if username != "local":
                userEl.addContent(username)
                query.addElement("registered")

        self.pytrans.send(reply)
开发者ID:2mf,项目名称:pyicqt,代码行数:28,代码来源:register.py

示例11: sendCommandList

# 需要导入模块: from twisted.words.xish.domish import Element [as 别名]
# 或者: from twisted.words.xish.domish.Element import attributes["id"] [as 别名]
	def sendCommandList(self, el):
		to = el.getAttribute("from")
		toj_uh = internJID(to).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"

		query = iq.addElement("query")
		query.attributes["xmlns"] = globals.DISCO_ITEMS
		query.attributes["node"] = globals.COMMANDS
		
		rights = rights_guest
		if toj_uh in self.pytrans.sessions: # logined
			rights = rights_user 
		if toj_uh in config.admins: # admin
			rights = rights_admin
			
		for command in self.commands:
			if self.commandRights[command] <= rights: # user can view this item (enough rights)
				item = query.addElement("item")
				item.attributes["jid"] = config.jid
				item.attributes["node"] = command
				item.attributes["name"] = lang.get(self.commandNames[command], ulang)

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

示例12: sendSearchForm

# 需要导入模块: from twisted.words.xish.domish import Element [as 别名]
# 或者: from twisted.words.xish.domish.Element import attributes["id"] [as 别名]
	def sendSearchForm(self, el):
		LogEvent(INFO)
		ulang = utils.getLang(el)
		iq = Element((None, "iq"))
		iq.attributes["type"] = "result"
		iq.attributes["from"] = el.getAttribute("to")
		iq.attributes["to"] = el.getAttribute("from")
		if el.getAttribute("id"):
			iq.attributes["id"] = el.getAttribute("id")
		query = iq.addElement("query")
		query.attributes["xmlns"] = globals.IQSEARCH
		forminstr = query.addElement("instructions")
		forminstr.addContent(lang.get("searchnodataform", ulang))
		x = query.addElement("x")
		x.attributes["xmlns"] = globals.XDATA
		x.attributes["type"] = "form"
		title = x.addElement("title")
		title.addContent(lang.get("searchtitle", ulang))
		instructions = x.addElement("instructions")
		instructions.addContent(lang.get("searchinstructions", ulang))
		x.addChild(utils.makeDataFormElement("hidden", "FORM_TYPE", value="jabber:iq:search"))
		x.addChild(utils.makeDataFormElement("text-single", "email", "E-Mail Address"))
		x.addChild(utils.makeDataFormElement("text-single", "first", "First Name"))
		x.addChild(utils.makeDataFormElement("text-single", "middle", "Middle Name"))
		x.addChild(utils.makeDataFormElement("text-single", "last", "Last Name"))
		x.addChild(utils.makeDataFormElement("text-single", "maiden", "Maiden Name"))
		x.addChild(utils.makeDataFormElement("text-single", "nick", "Nickname"))
		x.addChild(utils.makeDataFormElement("text-single", "address", "Street Address"))
		x.addChild(utils.makeDataFormElement("text-single", "city", "City"))
		x.addChild(utils.makeDataFormElement("text-single", "state", "State"))
		x.addChild(utils.makeDataFormElement("text-single", "zip", "Zip Code"))
		x.addChild(utils.makeDataFormElement("text-single", "country", "Country"))
		x.addChild(utils.makeDataFormElement("text-single", "interest", "Interest"))

		self.pytrans.send(iq)
开发者ID:Ashaman-,项目名称:pyaimt,代码行数:37,代码来源:SearchFactory.py

示例13: incomingIq

# 需要导入模块: from twisted.words.xish.domish import Element [as 别名]
# 或者: from twisted.words.xish.domish.Element import attributes["id"] [as 别名]
	def incomingIq(self, el):
		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")
		command.attributes["sessionid"] = self.pytrans.makeMessageID()
		command.attributes["xmlns"] = globals.COMMANDS
		command.attributes["status"] = "completed"

		x = command.addElement("x")
		x.attributes["xmlns"] = globals.XDATA
		x.attributes["type"] = "result"

		title = x.addElement("title")
		title.addContent(lang.get("command_Statistics", ulang))

		for key in self.stats:
			label = lang.get("statistics_%s" % key, ulang)
			description = lang.get("statistics_%s_Desc" % key, ulang)
			field = x.addElement("field")
			field.attributes["var"] = key
			field.attributes["label"] = label
			field.attributes["type"] = "text-single"
			field.addElement("value").addContent(str(self.stats[key]))
			field.addElement("desc").addContent(description)

		self.pytrans.send(iq)
开发者ID:Ashaman-,项目名称:pyaimt,代码行数:37,代码来源:Statistics.py

示例14: incomingIq

# 需要导入模块: from twisted.words.xish.domish import Element [as 别名]
# 或者: from twisted.words.xish.domish.Element import attributes["id"] [as 别名]
	def incomingIq(self, el):
		to = el.getAttribute("from")
		ID = el.getAttribute("id")
		ulang = utils.getLang(el)

		if config.admins.count(internJID(to).userhost()) == 0:
			self.pytrans.iq.sendIqError(to=to, fro=config.jid, ID=ID, xmlns=globals.COMMANDS, etype="cancel", condition="not-authorized")
			return

		self.sendProbes()

		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")
		command.attributes["sessionid"] = self.pytrans.makeMessageID()
		command.attributes["xmlns"] = globals.COMMANDS
		command.attributes["status"] = "completed"

		x = command.addElement("x")
		x.attributes["xmlns"] = globals.XDATA
		x.attributes["type"] = "result"

		title = x.addElement("title")
		title.addContent(lang.get("command_ConnectUsers", ulang))

		field = x.addElement("field")
		field.attributes["type"] = "fixed"
		field.addElement("value").addContent(lang.get("command_Done", ulang))

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

示例15: snfmtChangeResults

# 需要导入模块: from twisted.words.xish.domish import Element [as 别名]
# 或者: from twisted.words.xish.domish.Element import attributes["id"] [as 别名]
	def snfmtChangeResults(self, results, el, sessionid):
		to = el.getAttribute("from")
		toj = internJID(to)
		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"] = "formatscreenname"
		command.attributes["xmlns"] = globals.COMMANDS
		command.attributes["status"] = "completed"

		note = command.addElement("note")
		if results[3]:
			note.attributes["type"] = "error"
			note.addContent(results[3][1])
		else:
			note.attributes["type"] = "info"
			note.addContent(lang.get("command_Done", ulang))

		self.pytrans.send(iq)
开发者ID:Ashaman-,项目名称:pyaimt,代码行数:33,代码来源:FormatScreenName.py


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