summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2014-08-17 21:49:03 +0200
committerFlorent Le Coz <louiz@louiz.org>2014-09-01 02:47:15 +0200
commited37174a2b40d2d90aa6a0c7f778108687d39602 (patch)
tree307a0dd3468f9e7d96ef72676dadd50335efebbf
parent866014896091d83164a6503adf9035146cf49963 (diff)
downloadslixmpp-ed37174a2b40d2d90aa6a0c7f778108687d39602.tar.gz
slixmpp-ed37174a2b40d2d90aa6a0c7f778108687d39602.tar.bz2
slixmpp-ed37174a2b40d2d90aa6a0c7f778108687d39602.tar.xz
slixmpp-ed37174a2b40d2d90aa6a0c7f778108687d39602.zip
Always use OrderedDict from collections, and remove its implementation in slixmpp.thirdparty.
-rw-r--r--slixmpp/jid.py2
-rw-r--r--slixmpp/plugins/xep_0004/stanza/form.py2
-rw-r--r--slixmpp/plugins/xep_0071/stanza.py2
-rw-r--r--slixmpp/plugins/xep_0131/stanza.py2
-rw-r--r--slixmpp/stanza/stream_features.py2
-rw-r--r--slixmpp/thirdparty/__init__.py5
-rw-r--r--slixmpp/thirdparty/ordereddict.py127
-rw-r--r--slixmpp/xmlstream/stanzabase.py2
-rw-r--r--tests/test_stanza_element.py2
-rw-r--r--tests/test_stanza_xep_0004.py2
10 files changed, 8 insertions, 140 deletions
diff --git a/slixmpp/jid.py b/slixmpp/jid.py
index b7ebfbe9..1df7d1f0 100644
--- a/slixmpp/jid.py
+++ b/slixmpp/jid.py
@@ -22,7 +22,7 @@ import encodings.idna
from copy import deepcopy
from slixmpp.util import stringprep_profiles
-from slixmpp.thirdparty import OrderedDict
+from collections import OrderedDict
#: These characters are not allowed to appear in a JID.
ILLEGAL_CHARS = '\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r' + \
diff --git a/slixmpp/plugins/xep_0004/stanza/form.py b/slixmpp/plugins/xep_0004/stanza/form.py
index 1f900ee6..95e47b4f 100644
--- a/slixmpp/plugins/xep_0004/stanza/form.py
+++ b/slixmpp/plugins/xep_0004/stanza/form.py
@@ -9,7 +9,7 @@
import copy
import logging
-from slixmpp.thirdparty import OrderedDict
+from collections import OrderedDict
from slixmpp.xmlstream import ElementBase, ET
from slixmpp.plugins.xep_0004.stanza import FormField
diff --git a/slixmpp/plugins/xep_0071/stanza.py b/slixmpp/plugins/xep_0071/stanza.py
index d997cb3a..3df686cf 100644
--- a/slixmpp/plugins/xep_0071/stanza.py
+++ b/slixmpp/plugins/xep_0071/stanza.py
@@ -8,7 +8,7 @@
from slixmpp.stanza import Message
from slixmpp.util import unicode
-from slixmpp.thirdparty import OrderedDict
+from collections import OrderedDict
from slixmpp.xmlstream import ElementBase, ET, register_stanza_plugin, tostring
diff --git a/slixmpp/plugins/xep_0131/stanza.py b/slixmpp/plugins/xep_0131/stanza.py
index 4077d571..cbbe61a7 100644
--- a/slixmpp/plugins/xep_0131/stanza.py
+++ b/slixmpp/plugins/xep_0131/stanza.py
@@ -6,7 +6,7 @@
See the file LICENSE for copying permission.
"""
-from slixmpp.thirdparty import OrderedDict
+from collections import OrderedDict
from slixmpp.xmlstream import ET, ElementBase
diff --git a/slixmpp/stanza/stream_features.py b/slixmpp/stanza/stream_features.py
index 4d46b979..05788771 100644
--- a/slixmpp/stanza/stream_features.py
+++ b/slixmpp/stanza/stream_features.py
@@ -6,7 +6,7 @@
See the file LICENSE for copying permission.
"""
-from slixmpp.thirdparty import OrderedDict
+from collections import OrderedDict
from slixmpp.xmlstream import StanzaBase
diff --git a/slixmpp/thirdparty/__init__.py b/slixmpp/thirdparty/__init__.py
index fd6b5f72..5caa28d3 100644
--- a/slixmpp/thirdparty/__init__.py
+++ b/slixmpp/thirdparty/__init__.py
@@ -1,9 +1,4 @@
try:
- from collections import OrderedDict
-except:
- from slixmpp.thirdparty.ordereddict import OrderedDict
-
-try:
from gnupg import GPG
except:
from slixmpp.thirdparty.gnupg import GPG
diff --git a/slixmpp/thirdparty/ordereddict.py b/slixmpp/thirdparty/ordereddict.py
deleted file mode 100644
index 5b0303f5..00000000
--- a/slixmpp/thirdparty/ordereddict.py
+++ /dev/null
@@ -1,127 +0,0 @@
-# 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.
-
-from UserDict import DictMixin
-
-class OrderedDict(dict, DictMixin):
-
- def __init__(self, *args, **kwds):
- if len(args) > 1:
- raise TypeError('expected at most 1 arguments, got %d' % len(args))
- try:
- self.__end
- except AttributeError:
- self.clear()
- self.update(*args, **kwds)
-
- def clear(self):
- self.__end = end = []
- end += [None, end, end] # sentinel node for doubly linked list
- self.__map = {} # key --> [key, prev, next]
- dict.clear(self)
-
- def __setitem__(self, key, value):
- if key not in self:
- end = self.__end
- curr = end[1]
- curr[2] = end[1] = self.__map[key] = [key, curr, end]
- dict.__setitem__(self, key, value)
-
- def __delitem__(self, key):
- dict.__delitem__(self, key)
- key, prev, next = self.__map.pop(key)
- prev[2] = next
- next[1] = prev
-
- def __iter__(self):
- end = self.__end
- curr = end[2]
- while curr is not end:
- yield curr[0]
- curr = curr[2]
-
- def __reversed__(self):
- end = self.__end
- curr = end[1]
- while curr is not end:
- yield curr[0]
- curr = curr[1]
-
- def popitem(self, last=True):
- if not self:
- raise KeyError('dictionary is empty')
- if last:
- key = reversed(self).next()
- else:
- key = iter(self).next()
- value = self.pop(key)
- return key, value
-
- def __reduce__(self):
- items = [[k, self[k]] for k in self]
- tmp = self.__map, self.__end
- del self.__map, self.__end
- inst_dict = vars(self).copy()
- self.__map, self.__end = tmp
- if inst_dict:
- return (self.__class__, (items,), inst_dict)
- return self.__class__, (items,)
-
- def keys(self):
- return list(self)
-
- setdefault = DictMixin.setdefault
- update = DictMixin.update
- pop = DictMixin.pop
- values = DictMixin.values
- items = DictMixin.items
- iterkeys = DictMixin.iterkeys
- itervalues = DictMixin.itervalues
- iteritems = DictMixin.iteritems
-
- def __repr__(self):
- if not self:
- return '%s()' % (self.__class__.__name__,)
- return '%s(%r)' % (self.__class__.__name__, self.items())
-
- def copy(self):
- return self.__class__(self)
-
- @classmethod
- def fromkeys(cls, iterable, value=None):
- d = cls()
- for key in iterable:
- d[key] = value
- return d
-
- def __eq__(self, other):
- if isinstance(other, OrderedDict):
- if len(self) != len(other):
- return False
- for p, q in zip(self.items(), other.items()):
- if p != q:
- return False
- return True
- return dict.__eq__(self, other)
-
- def __ne__(self, other):
- return not self == other
diff --git a/slixmpp/xmlstream/stanzabase.py b/slixmpp/xmlstream/stanzabase.py
index 8634250f..3f469153 100644
--- a/slixmpp/xmlstream/stanzabase.py
+++ b/slixmpp/xmlstream/stanzabase.py
@@ -21,7 +21,7 @@ from xml.etree import cElementTree as ET
from slixmpp.xmlstream import JID
from slixmpp.xmlstream.tostring import tostring
-from slixmpp.thirdparty import OrderedDict
+from collections import OrderedDict
log = logging.getLogger(__name__)
diff --git a/tests/test_stanza_element.py b/tests/test_stanza_element.py
index 9241ed46..52ca87f0 100644
--- a/tests/test_stanza_element.py
+++ b/tests/test_stanza_element.py
@@ -1,7 +1,7 @@
import unittest
from slixmpp.test import SlixTest
from slixmpp.xmlstream.stanzabase import ElementBase, register_stanza_plugin, ET
-from slixmpp.thirdparty import OrderedDict
+from collections import OrderedDict
class TestElementBase(SlixTest):
diff --git a/tests/test_stanza_xep_0004.py b/tests/test_stanza_xep_0004.py
index 93f2703b..b95b64ca 100644
--- a/tests/test_stanza_xep_0004.py
+++ b/tests/test_stanza_xep_0004.py
@@ -1,7 +1,7 @@
import unittest
from slixmpp import Message
from slixmpp.test import SlixTest
-from slixmpp.thirdparty import OrderedDict
+from collections import OrderedDict
import slixmpp.plugins.xep_0004 as xep_0004
from slixmpp.xmlstream import register_stanza_plugin