From d14045f5a6eec370f0374b1e7dab6eb58bc70d48 Mon Sep 17 00:00:00 2001 From: Nathan Fritz Date: Sat, 9 Jan 2010 13:17:08 -0800 Subject: [PATCH] added stanza.get(key, defaultvalue) --- sleekxmpp/xmlstream/stanzabase.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sleekxmpp/xmlstream/stanzabase.py b/sleekxmpp/xmlstream/stanzabase.py index d4c1118f..8bdcb0b0 100644 --- a/sleekxmpp/xmlstream/stanzabase.py +++ b/sleekxmpp/xmlstream/stanzabase.py @@ -71,6 +71,12 @@ class ElementBase(object): self.xml.remove(aff.xml) return aff + def get(self, key, defaultvalue=None): + value = self[key] + if value is None or value == '': + return defaultvalue + return value + def keys(self): out = [] out += [x for x in self.interfaces]