summaryrefslogtreecommitdiff
path: root/slixmpp
diff options
context:
space:
mode:
authorEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2020-12-06 16:34:52 +0100
committerEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2020-12-06 17:00:47 +0100
commitcd4c9f82fc8d17726baa4b4a69c54151fb181f40 (patch)
treed47b5d13b0d79f6526661bf23caebbef9c57d136 /slixmpp
parent05749c49690c00f2b1794212b2fb9281b6956a89 (diff)
downloadslixmpp-cd4c9f82fc8d17726baa4b4a69c54151fb181f40.tar.gz
slixmpp-cd4c9f82fc8d17726baa4b4a69c54151fb181f40.tar.bz2
slixmpp-cd4c9f82fc8d17726baa4b4a69c54151fb181f40.tar.xz
slixmpp-cd4c9f82fc8d17726baa4b4a69c54151fb181f40.zip
Remove OrderedDict usage
We now support only Python 3.7+, this means we can rely on dict being ordered by order of insertion, and thus no need to use OrderedDict from collections.
Diffstat (limited to 'slixmpp')
-rw-r--r--slixmpp/plugins/xep_0004/stanza/form.py9
-rw-r--r--slixmpp/plugins/xep_0071/stanza.py3
-rw-r--r--slixmpp/plugins/xep_0131/stanza.py3
-rw-r--r--slixmpp/stanza/stream_features.py3
-rw-r--r--slixmpp/xmlstream/stanzabase.py11
5 files changed, 10 insertions, 19 deletions
diff --git a/slixmpp/plugins/xep_0004/stanza/form.py b/slixmpp/plugins/xep_0004/stanza/form.py
index ff1a51fb..526911db 100644
--- a/slixmpp/plugins/xep_0004/stanza/form.py
+++ b/slixmpp/plugins/xep_0004/stanza/form.py
@@ -9,7 +9,6 @@
import copy
import logging
-from collections import OrderedDict
from slixmpp.thirdparty import OrderedSet
from slixmpp.xmlstream import ElementBase, ET
@@ -133,7 +132,7 @@ class Form(ElementBase):
self.xml.remove(reportedXML)
def get_fields(self, use_dict=False):
- fields = OrderedDict()
+ fields = {}
for stanza in self['substanzas']:
if isinstance(stanza, FormField):
fields[stanza['var']] = stanza
@@ -147,7 +146,7 @@ class Form(ElementBase):
items = []
itemsXML = self.xml.findall('{%s}item' % self.namespace)
for itemXML in itemsXML:
- item = OrderedDict()
+ item = {}
fieldsXML = itemXML.findall('{%s}field' % FormField.namespace)
for fieldXML in fieldsXML:
field = FormField(xml=fieldXML)
@@ -156,7 +155,7 @@ class Form(ElementBase):
return items
def get_reported(self):
- fields = OrderedDict()
+ fields = {}
xml = self.xml.findall('{%s}reported/{%s}field' % (self.namespace,
FormField.namespace))
for field in xml:
@@ -165,7 +164,7 @@ class Form(ElementBase):
return fields
def get_values(self):
- values = OrderedDict()
+ values = {}
fields = self.get_fields()
for var in fields:
values[var] = fields[var]['value']
diff --git a/slixmpp/plugins/xep_0071/stanza.py b/slixmpp/plugins/xep_0071/stanza.py
index 4c3380c4..47951976 100644
--- a/slixmpp/plugins/xep_0071/stanza.py
+++ b/slixmpp/plugins/xep_0071/stanza.py
@@ -8,7 +8,6 @@
from slixmpp.stanza import Message
from slixmpp.util import unicode
-from collections import OrderedDict
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)
if lang == '*':
- result = OrderedDict()
+ result = {}
for body in bodies:
body_lang = body.attrib.get('{%s}lang' % self.xml_ns, '')
body_result = []
diff --git a/slixmpp/plugins/xep_0131/stanza.py b/slixmpp/plugins/xep_0131/stanza.py
index d075c15e..9f7bfa36 100644
--- a/slixmpp/plugins/xep_0131/stanza.py
+++ b/slixmpp/plugins/xep_0131/stanza.py
@@ -6,7 +6,6 @@
See the file LICENSE for copying permission.
"""
-from collections import OrderedDict
from slixmpp.xmlstream import ET, ElementBase
@@ -18,7 +17,7 @@ class Headers(ElementBase):
is_extension = True
def get_headers(self):
- result = OrderedDict()
+ result = {}
headers = self.xml.findall('{%s}header' % self.namespace)
for header in headers:
name = header.attrib.get('name', '')
diff --git a/slixmpp/stanza/stream_features.py b/slixmpp/stanza/stream_features.py
index 70d0ccca..027747a1 100644
--- a/slixmpp/stanza/stream_features.py
+++ b/slixmpp/stanza/stream_features.py
@@ -6,7 +6,6 @@
See the file LICENSE for copying permission.
"""
-from collections import OrderedDict
from slixmpp.xmlstream import StanzaBase
@@ -29,7 +28,7 @@ class StreamFeatures(StanzaBase):
def get_features(self):
"""
"""
- features = OrderedDict()
+ features = {}
for (name, lang), plugin in self.plugins.items():
features[name] = plugin
return features
diff --git a/slixmpp/xmlstream/stanzabase.py b/slixmpp/xmlstream/stanzabase.py
index 925f2abc..141197ba 100644
--- a/slixmpp/xmlstream/stanzabase.py
+++ b/slixmpp/xmlstream/stanzabase.py
@@ -21,7 +21,6 @@ from xml.etree import ElementTree as ET
from slixmpp.xmlstream import JID
from slixmpp.xmlstream.tostring import tostring
-from collections import OrderedDict
log = logging.getLogger(__name__)
@@ -392,7 +391,7 @@ class ElementBase(object):
#: An ordered dictionary of plugin stanzas, mapped by their
#: :attr:`plugin_attrib` value.
- self.plugins = OrderedDict()
+ self.plugins = {}
self.loaded_plugins = set()
#: A list of child stanzas whose class is included in
@@ -541,7 +540,7 @@ class ElementBase(object):
.. versionadded:: 1.0-Beta1
"""
- values = OrderedDict()
+ values = {}
values['lang'] = self['lang']
for interface in self.interfaces:
if isinstance(self[interface], JID):
@@ -726,8 +725,6 @@ class ElementBase(object):
if lang and attrib in self.lang_interfaces:
kwargs['lang'] = lang
- kwargs = OrderedDict(kwargs)
-
if attrib in self.interfaces or attrib == 'lang':
if value is not None:
set_method = "set_%s" % attrib.lower()
@@ -813,8 +810,6 @@ class ElementBase(object):
if lang and attrib in self.lang_interfaces:
kwargs['lang'] = lang
- kwargs = OrderedDict(kwargs)
-
if attrib in self.interfaces or attrib == 'lang':
del_method = "del_%s" % attrib.lower()
@@ -929,7 +924,7 @@ class ElementBase(object):
name = self._fix_ns(name)
default_lang = self.get_lang()
- results = OrderedDict()
+ results = {}
stanzas = self.xml.findall(name)
if stanzas:
for stanza in stanzas: