Merge branch 'no-ordered-stuff' into 'master'
Remove usage of OrderedDict See merge request poezio/slixmpp!77
This commit is contained in:
commit
bcd8cf085f
8 changed files with 14 additions and 53 deletions
28
LICENSE
28
LICENSE
|
@ -86,34 +86,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
OrderedDict - A port of the Python 2.7+ OrderedDict to Python 2.6
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
Copyright (c) 2009 Raymond Hettinger
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person
|
|
||||||
obtaining a copy of this software and associated documentation files
|
|
||||||
(the "Software"), to deal in the Software without restriction,
|
|
||||||
including without limitation the rights to use, copy, modify, merge,
|
|
||||||
publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
and to permit persons to whom the Software is furnished to do so,
|
|
||||||
subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be
|
|
||||||
included in all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
||||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
||||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
||||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
||||||
OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SUELTA – A PURE-PYTHON SASL CLIENT LIBRARY
|
SUELTA – A PURE-PYTHON SASL CLIENT LIBRARY
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
import copy
|
import copy
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from collections import OrderedDict
|
|
||||||
from slixmpp.thirdparty import OrderedSet
|
from slixmpp.thirdparty import OrderedSet
|
||||||
|
|
||||||
from slixmpp.xmlstream import ElementBase, ET
|
from slixmpp.xmlstream import ElementBase, ET
|
||||||
|
@ -133,7 +132,7 @@ class Form(ElementBase):
|
||||||
self.xml.remove(reportedXML)
|
self.xml.remove(reportedXML)
|
||||||
|
|
||||||
def get_fields(self, use_dict=False):
|
def get_fields(self, use_dict=False):
|
||||||
fields = OrderedDict()
|
fields = {}
|
||||||
for stanza in self['substanzas']:
|
for stanza in self['substanzas']:
|
||||||
if isinstance(stanza, FormField):
|
if isinstance(stanza, FormField):
|
||||||
fields[stanza['var']] = stanza
|
fields[stanza['var']] = stanza
|
||||||
|
@ -147,7 +146,7 @@ class Form(ElementBase):
|
||||||
items = []
|
items = []
|
||||||
itemsXML = self.xml.findall('{%s}item' % self.namespace)
|
itemsXML = self.xml.findall('{%s}item' % self.namespace)
|
||||||
for itemXML in itemsXML:
|
for itemXML in itemsXML:
|
||||||
item = OrderedDict()
|
item = {}
|
||||||
fieldsXML = itemXML.findall('{%s}field' % FormField.namespace)
|
fieldsXML = itemXML.findall('{%s}field' % FormField.namespace)
|
||||||
for fieldXML in fieldsXML:
|
for fieldXML in fieldsXML:
|
||||||
field = FormField(xml=fieldXML)
|
field = FormField(xml=fieldXML)
|
||||||
|
@ -156,7 +155,7 @@ class Form(ElementBase):
|
||||||
return items
|
return items
|
||||||
|
|
||||||
def get_reported(self):
|
def get_reported(self):
|
||||||
fields = OrderedDict()
|
fields = {}
|
||||||
xml = self.xml.findall('{%s}reported/{%s}field' % (self.namespace,
|
xml = self.xml.findall('{%s}reported/{%s}field' % (self.namespace,
|
||||||
FormField.namespace))
|
FormField.namespace))
|
||||||
for field in xml:
|
for field in xml:
|
||||||
|
@ -165,7 +164,7 @@ class Form(ElementBase):
|
||||||
return fields
|
return fields
|
||||||
|
|
||||||
def get_values(self):
|
def get_values(self):
|
||||||
values = OrderedDict()
|
values = {}
|
||||||
fields = self.get_fields()
|
fields = self.get_fields()
|
||||||
for var in fields:
|
for var in fields:
|
||||||
values[var] = fields[var]['value']
|
values[var] = fields[var]['value']
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
|
|
||||||
from slixmpp.stanza import Message
|
from slixmpp.stanza import Message
|
||||||
from slixmpp.util import unicode
|
from slixmpp.util import unicode
|
||||||
from collections import OrderedDict
|
|
||||||
from slixmpp.xmlstream import ElementBase, ET, register_stanza_plugin, tostring
|
from slixmpp.xmlstream import ElementBase, ET, register_stanza_plugin, tostring
|
||||||
|
|
||||||
|
|
||||||
|
@ -50,7 +49,7 @@ class XHTML_IM(ElementBase):
|
||||||
bodies = self.xml.findall('{%s}body' % XHTML_NS)
|
bodies = self.xml.findall('{%s}body' % XHTML_NS)
|
||||||
|
|
||||||
if lang == '*':
|
if lang == '*':
|
||||||
result = OrderedDict()
|
result = {}
|
||||||
for body in bodies:
|
for body in bodies:
|
||||||
body_lang = body.attrib.get('{%s}lang' % self.xml_ns, '')
|
body_lang = body.attrib.get('{%s}lang' % self.xml_ns, '')
|
||||||
body_result = []
|
body_result = []
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
See the file LICENSE for copying permission.
|
See the file LICENSE for copying permission.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from collections import OrderedDict
|
|
||||||
from slixmpp.xmlstream import ET, ElementBase
|
from slixmpp.xmlstream import ET, ElementBase
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,7 +17,7 @@ class Headers(ElementBase):
|
||||||
is_extension = True
|
is_extension = True
|
||||||
|
|
||||||
def get_headers(self):
|
def get_headers(self):
|
||||||
result = OrderedDict()
|
result = {}
|
||||||
headers = self.xml.findall('{%s}header' % self.namespace)
|
headers = self.xml.findall('{%s}header' % self.namespace)
|
||||||
for header in headers:
|
for header in headers:
|
||||||
name = header.attrib.get('name', '')
|
name = header.attrib.get('name', '')
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
See the file LICENSE for copying permission.
|
See the file LICENSE for copying permission.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from collections import OrderedDict
|
|
||||||
from slixmpp.xmlstream import StanzaBase
|
from slixmpp.xmlstream import StanzaBase
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,7 +28,7 @@ class StreamFeatures(StanzaBase):
|
||||||
def get_features(self):
|
def get_features(self):
|
||||||
"""
|
"""
|
||||||
"""
|
"""
|
||||||
features = OrderedDict()
|
features = {}
|
||||||
for (name, lang), plugin in self.plugins.items():
|
for (name, lang), plugin in self.plugins.items():
|
||||||
features[name] = plugin
|
features[name] = plugin
|
||||||
return features
|
return features
|
||||||
|
|
|
@ -21,7 +21,6 @@ from xml.etree import ElementTree as ET
|
||||||
|
|
||||||
from slixmpp.xmlstream import JID
|
from slixmpp.xmlstream import JID
|
||||||
from slixmpp.xmlstream.tostring import tostring
|
from slixmpp.xmlstream.tostring import tostring
|
||||||
from collections import OrderedDict
|
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
@ -392,7 +391,7 @@ class ElementBase(object):
|
||||||
|
|
||||||
#: An ordered dictionary of plugin stanzas, mapped by their
|
#: An ordered dictionary of plugin stanzas, mapped by their
|
||||||
#: :attr:`plugin_attrib` value.
|
#: :attr:`plugin_attrib` value.
|
||||||
self.plugins = OrderedDict()
|
self.plugins = {}
|
||||||
self.loaded_plugins = set()
|
self.loaded_plugins = set()
|
||||||
|
|
||||||
#: A list of child stanzas whose class is included in
|
#: A list of child stanzas whose class is included in
|
||||||
|
@ -541,7 +540,7 @@ class ElementBase(object):
|
||||||
|
|
||||||
.. versionadded:: 1.0-Beta1
|
.. versionadded:: 1.0-Beta1
|
||||||
"""
|
"""
|
||||||
values = OrderedDict()
|
values = {}
|
||||||
values['lang'] = self['lang']
|
values['lang'] = self['lang']
|
||||||
for interface in self.interfaces:
|
for interface in self.interfaces:
|
||||||
if isinstance(self[interface], JID):
|
if isinstance(self[interface], JID):
|
||||||
|
@ -726,8 +725,6 @@ class ElementBase(object):
|
||||||
if lang and attrib in self.lang_interfaces:
|
if lang and attrib in self.lang_interfaces:
|
||||||
kwargs['lang'] = lang
|
kwargs['lang'] = lang
|
||||||
|
|
||||||
kwargs = OrderedDict(kwargs)
|
|
||||||
|
|
||||||
if attrib in self.interfaces or attrib == 'lang':
|
if attrib in self.interfaces or attrib == 'lang':
|
||||||
if value is not None:
|
if value is not None:
|
||||||
set_method = "set_%s" % attrib.lower()
|
set_method = "set_%s" % attrib.lower()
|
||||||
|
@ -813,8 +810,6 @@ class ElementBase(object):
|
||||||
if lang and attrib in self.lang_interfaces:
|
if lang and attrib in self.lang_interfaces:
|
||||||
kwargs['lang'] = lang
|
kwargs['lang'] = lang
|
||||||
|
|
||||||
kwargs = OrderedDict(kwargs)
|
|
||||||
|
|
||||||
if attrib in self.interfaces or attrib == 'lang':
|
if attrib in self.interfaces or attrib == 'lang':
|
||||||
del_method = "del_%s" % attrib.lower()
|
del_method = "del_%s" % attrib.lower()
|
||||||
|
|
||||||
|
@ -929,7 +924,7 @@ class ElementBase(object):
|
||||||
name = self._fix_ns(name)
|
name = self._fix_ns(name)
|
||||||
|
|
||||||
default_lang = self.get_lang()
|
default_lang = self.get_lang()
|
||||||
results = OrderedDict()
|
results = {}
|
||||||
stanzas = self.xml.findall(name)
|
stanzas = self.xml.findall(name)
|
||||||
if stanzas:
|
if stanzas:
|
||||||
for stanza in stanzas:
|
for stanza in stanzas:
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import unittest
|
import unittest
|
||||||
from slixmpp.test import SlixTest
|
from slixmpp.test import SlixTest
|
||||||
from slixmpp.xmlstream.stanzabase import ElementBase, register_stanza_plugin, ET
|
from slixmpp.xmlstream.stanzabase import ElementBase, register_stanza_plugin, ET
|
||||||
from collections import OrderedDict
|
|
||||||
|
|
||||||
|
|
||||||
class TestElementBase(SlixTest):
|
class TestElementBase(SlixTest):
|
||||||
|
@ -1221,7 +1220,7 @@ class TestElementBase(SlixTest):
|
||||||
sub_interfaces = interfaces
|
sub_interfaces = interfaces
|
||||||
lang_interfaces = interfaces
|
lang_interfaces = interfaces
|
||||||
|
|
||||||
data = OrderedDict()
|
data = {}
|
||||||
data['en'] = 'hi'
|
data['en'] = 'hi'
|
||||||
data['fr'] = 'bonjour'
|
data['fr'] = 'bonjour'
|
||||||
data['no'] = 'hej'
|
data['no'] = 'hej'
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import unittest
|
import unittest
|
||||||
from slixmpp import Message
|
from slixmpp import Message
|
||||||
from slixmpp.test import SlixTest
|
from slixmpp.test import SlixTest
|
||||||
from collections import OrderedDict
|
|
||||||
|
|
||||||
import slixmpp.plugins.xep_0004 as xep_0004
|
import slixmpp.plugins.xep_0004 as xep_0004
|
||||||
from slixmpp.xmlstream import register_stanza_plugin
|
from slixmpp.xmlstream import register_stanza_plugin
|
||||||
|
@ -52,7 +51,7 @@ class TestDataForms(SlixTest):
|
||||||
</message>
|
</message>
|
||||||
""")
|
""")
|
||||||
|
|
||||||
fields = OrderedDict()
|
fields = {}
|
||||||
fields['f1'] = {'type': 'text-single',
|
fields['f1'] = {'type': 'text-single',
|
||||||
'label': 'Username',
|
'label': 'Username',
|
||||||
'required': True}
|
'required': True}
|
||||||
|
@ -125,7 +124,7 @@ class TestDataForms(SlixTest):
|
||||||
msg = self.Message()
|
msg = self.Message()
|
||||||
form = msg['form']
|
form = msg['form']
|
||||||
|
|
||||||
fields = OrderedDict()
|
fields = {}
|
||||||
fields['f1'] = {'type': 'text-single',
|
fields['f1'] = {'type': 'text-single',
|
||||||
'label': 'Username',
|
'label': 'Username',
|
||||||
'required': True}
|
'required': True}
|
||||||
|
@ -173,7 +172,7 @@ class TestDataForms(SlixTest):
|
||||||
msg = self.Message()
|
msg = self.Message()
|
||||||
form = msg['form']
|
form = msg['form']
|
||||||
|
|
||||||
fields = OrderedDict()
|
fields = {}
|
||||||
fields['f1'] = {'type': 'text-single',
|
fields['f1'] = {'type': 'text-single',
|
||||||
'label': 'Username',
|
'label': 'Username',
|
||||||
'required': True}
|
'required': True}
|
||||||
|
|
Loading…
Reference in a new issue