core, plugins: fixed bad use of children instead of elements() for domish.Element instances.
This commit is contained in:
parent
58561b8732
commit
eb60e0ff33
7 changed files with 19 additions and 19 deletions
|
|
@ -212,7 +212,7 @@ class GroupBlog(object):
|
|||
|
||||
def _parseAccessData(self, microblog_data, item):
|
||||
P = self.host.plugins["XEP-0060"]
|
||||
form_elts = filter(lambda elt: elt.name == "x", item.children)
|
||||
form_elts = [child for child in item.elements() if child.name == "x"]
|
||||
for form_elt in form_elts:
|
||||
form = data_form.Form.fromElement(form_elt)
|
||||
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ class Quiz(object):
|
|||
@param answer_result_elt: answer result element
|
||||
@return: (player, good_answer, score)"""
|
||||
score = {}
|
||||
for score_elt in answer_result_elt.children:
|
||||
for score_elt in answer_result_elt.elements():
|
||||
score[score_elt['player']] = int(score_elt['score'])
|
||||
return (answer_result_elt['player'], answer_result_elt['good_answer'] == str(True), score)
|
||||
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ class XEP_0020(object):
|
|||
"""Check element's children to find feature elements
|
||||
@param elt: domish.Element
|
||||
@return: feature elements"""
|
||||
return filter(lambda elt: elt.name == 'feature', elt.elements())
|
||||
return [child for child in elt.elements() if child.name == 'feature']
|
||||
|
||||
def getChoosedOptions(self, elt):
|
||||
"""Return choosed feature for feature element
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ try:
|
|||
except ImportError:
|
||||
from wokkel.subprotocols import XMPPHandler
|
||||
from threading import Timer
|
||||
from twisted.words.xish.domish import generateElementsNamed
|
||||
from twisted.words.xish import domish
|
||||
|
||||
NS_XMPP_CLIENT = "jabber:client"
|
||||
NS_CHAT_STATES = "http://jabber.org/protocol/chatstates"
|
||||
|
|
@ -143,10 +143,10 @@ class XEP_0085(object):
|
|||
return True
|
||||
|
||||
try:
|
||||
generateElementsNamed(message.children, name="body").next()
|
||||
domish.generateElementsNamed(message.elements(), name="body").next()
|
||||
from_jid = JID(message.getAttribute("from"))
|
||||
try:
|
||||
generateElementsNamed(message.children, name="active").next()
|
||||
domish.generateElementsNamed(message.elements(), name="active").next()
|
||||
# contact enabled Chat State Notifications
|
||||
self.updateEntityData(from_jid, True, profile)
|
||||
# init to send following "composing" state
|
||||
|
|
@ -158,7 +158,7 @@ class XEP_0085(object):
|
|||
except StopIteration:
|
||||
pass
|
||||
|
||||
state_list = [child.name for child in message.children if
|
||||
state_list = [child.name for child in message.elements() if
|
||||
message.getAttribute("type") in MESSAGE_TYPES
|
||||
and child.name in CHAT_STATES
|
||||
and child.defaultUri == NS_CHAT_STATES]
|
||||
|
|
@ -178,7 +178,7 @@ class XEP_0085(object):
|
|||
return True
|
||||
try:
|
||||
# message with a body always mean active state
|
||||
generateElementsNamed(message.children, name="body").next()
|
||||
domish.generateElementsNamed(message.elements(), name="body").next()
|
||||
message.addElement('active', NS_CHAT_STATES)
|
||||
# launch the chat state machine (init the timer)
|
||||
self.__chatStateActive(to_jid, mess_data["type"], profile)
|
||||
|
|
|
|||
|
|
@ -104,15 +104,15 @@ class XEP_0163(object):
|
|||
debug(_("No item found"))
|
||||
return
|
||||
try:
|
||||
mood_elem = filter(lambda x: x.name == "mood", itemsEvent.items[0].children)[0]
|
||||
except KeyError:
|
||||
mood_elt = [child for child in itemsEvent.items[0].elements() if child.name == "mood"][0]
|
||||
except IndexError:
|
||||
error(_("Can't find mood element in mood event"))
|
||||
return
|
||||
_mood = Mood.fromXml(mood_elem)
|
||||
if not _mood:
|
||||
mood = Mood.fromXml(mood_elt)
|
||||
if not mood:
|
||||
debug(_("No mood found"))
|
||||
return
|
||||
self.host.bridge.personalEvent(itemsEvent.sender.full(), "MOOD", {"mood": _mood.value or "", "text": _mood.text or ""}, profile)
|
||||
self.host.bridge.personalEvent(itemsEvent.sender.full(), "MOOD", {"mood": mood.value or "", "text": mood.text or ""}, profile)
|
||||
|
||||
def sendMood(self, data, profile):
|
||||
"""Send XEP-0107's User Mood
|
||||
|
|
@ -124,8 +124,8 @@ class XEP_0163(object):
|
|||
except KeyError:
|
||||
error(_("Mood data must contain at least 'mood' key"))
|
||||
return 3
|
||||
_mood = UserMood(value, text)
|
||||
self.sendPEPEvent(NS_USER_MOOD, _mood, profile)
|
||||
mood = UserMood(value, text)
|
||||
self.sendPEPEvent(NS_USER_MOOD, mood, profile)
|
||||
return 0
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -85,8 +85,8 @@ class XEP_0277(object):
|
|||
@param item: domish.Element of microblog item
|
||||
@return: microblog data (dictionary)"""
|
||||
try:
|
||||
entry_elt = filter(lambda x: x.name == "entry", item.children)[0]
|
||||
except KeyError:
|
||||
entry_elt = [child for child in item.elements() if child.name == "entry"][0]
|
||||
except IndexError:
|
||||
warning(_('No entry element in microblog item'))
|
||||
return
|
||||
_entry = atom.Entry().import_xml(entry_elt.toXml().encode('utf-8'))
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ def dataFormResult2AdvancedList(form_ui, form_xml):
|
|||
except StopIteration:
|
||||
raise exceptions.DataError("Couldn't find expected <reported> tag")
|
||||
|
||||
for elt in reported_elt.children:
|
||||
for elt in reported_elt.elements():
|
||||
if elt.name != "field":
|
||||
raise exceptions.DataError("Unexpected tag")
|
||||
name = elt["var"]
|
||||
|
|
@ -90,7 +90,7 @@ def dataFormResult2AdvancedList(form_ui, form_xml):
|
|||
|
||||
for item_elt in item_elts:
|
||||
fields = []
|
||||
for elt in item_elt.children:
|
||||
for elt in item_elt.elements():
|
||||
if elt.name != 'field':
|
||||
warning("Unexpected tag (%s)" % elt.name)
|
||||
continue
|
||||
|
|
|
|||
Loading…
Reference in a new issue