summaryrefslogtreecommitdiff
path: root/sleekxmpp/xmlstream/stanzabase.py
diff options
context:
space:
mode:
authorNathan Fritz <fritzy@netflint.net>2010-01-25 10:40:50 -0800
committerNathan Fritz <fritzy@netflint.net>2010-01-25 10:40:50 -0800
commit65dd83d4e174fc5f88ea90b32dd9e3ebf1787294 (patch)
tree9710ceeebb74d49c6ae1926bae7be5188c4a9066 /sleekxmpp/xmlstream/stanzabase.py
parent6e4c1128ec8f01d31c7714c13db02ff20c7a0a40 (diff)
parent6b130eb94775da8675750a0a9aed75fa6f328137 (diff)
downloadslixmpp-65dd83d4e174fc5f88ea90b32dd9e3ebf1787294.tar.gz
slixmpp-65dd83d4e174fc5f88ea90b32dd9e3ebf1787294.tar.bz2
slixmpp-65dd83d4e174fc5f88ea90b32dd9e3ebf1787294.tar.xz
slixmpp-65dd83d4e174fc5f88ea90b32dd9e3ebf1787294.zip
Merge branch 'master' of github.com:fritzy/SleekXMPP
Diffstat (limited to 'sleekxmpp/xmlstream/stanzabase.py')
-rw-r--r--sleekxmpp/xmlstream/stanzabase.py33
1 files changed, 27 insertions, 6 deletions
diff --git a/sleekxmpp/xmlstream/stanzabase.py b/sleekxmpp/xmlstream/stanzabase.py
index 277882e8..feb9b268 100644
--- a/sleekxmpp/xmlstream/stanzabase.py
+++ b/sleekxmpp/xmlstream/stanzabase.py
@@ -2,6 +2,8 @@ from xml.etree import cElementTree as ET
import logging
import traceback
+xmltester = type(ET.Element('xml'))
+
class JID(object):
def __init__(self, jid):
self.jid = jid
@@ -62,7 +64,10 @@ class ElementBase(object):
def append(self, item):
if not isinstance(item, ElementBase):
- raise TypeError
+ if type(item) == xmltester:
+ return self.appendxml(item)
+ else:
+ raise TypeError
self.xml.append(item.xml)
self.iterables.append(item)
return self
@@ -86,11 +91,27 @@ class ElementBase(object):
out.append('substanzas')
return tuple(out)
- def find(self, item):
- return self.iterables.find(item)
-
- def match(self, xml):
- return xml.tag == self.tag
+ def match(self, matchstring):
+ if isinstance(matchstring, str):
+ nodes = matchstring.split('/')
+ else:
+ nodes = matchstring
+ tagargs = nodes[0].split('@')
+ if tagargs[0] not in (self.plugins, self.name): return False
+ founditerable = False
+ for iterable in self.iterables:
+ founditerable = iterable.match(nodes[1:])
+ if founditerable: break;
+ for evals in tagargs[1:]:
+ x,y = evals.split('=')
+ if self[x] != y: return False
+ if not founditerable and len(nodes) > 1:
+ next = nodes[1].split('@')[0]
+ if next in self.plugins:
+ return self.plugins[next].match(nodes[1:])
+ else:
+ return False
+ return True
def find(self, xpath): # for backwards compatiblity, expose elementtree interface
return self.xml.find(xpath)