don't need odict anymore
This commit is contained in:
parent
929ce8df7a
commit
bfe8fac5bf
|
@ -26,7 +26,6 @@ import UserDict
|
||||||
|
|
||||||
from paramiko.common import *
|
from paramiko.common import *
|
||||||
from paramiko.dsskey import DSSKey
|
from paramiko.dsskey import DSSKey
|
||||||
from paramiko.odict import odict
|
|
||||||
from paramiko.rsakey import RSAKey
|
from paramiko.rsakey import RSAKey
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,63 +0,0 @@
|
||||||
#
|
|
||||||
# This file and source code are in the public domain.
|
|
||||||
#
|
|
||||||
|
|
||||||
class odict (dict):
|
|
||||||
"""
|
|
||||||
A dictionary with ordered keys. Based on the cookbook recipe at:
|
|
||||||
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/107747
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self, *larg, **kwarg):
|
|
||||||
self._keys = []
|
|
||||||
dict.__init__(self, *larg, **kwarg)
|
|
||||||
|
|
||||||
def __delitem__(self, key):
|
|
||||||
dict.__delitem__(self, key)
|
|
||||||
self._keys.remove(key)
|
|
||||||
|
|
||||||
def __setitem__(self, key, item):
|
|
||||||
dict.__setitem__(self, key, item)
|
|
||||||
if key not in self._keys:
|
|
||||||
self._keys.append(key)
|
|
||||||
|
|
||||||
def clear(self):
|
|
||||||
dict.clear(self)
|
|
||||||
self._keys = []
|
|
||||||
|
|
||||||
def copy(self):
|
|
||||||
od = odict(self)
|
|
||||||
return od
|
|
||||||
|
|
||||||
def items(self):
|
|
||||||
return zip(self._keys, self.values())
|
|
||||||
|
|
||||||
def iteritems(self):
|
|
||||||
for k in self._keys:
|
|
||||||
yield k, self[k]
|
|
||||||
|
|
||||||
def keys(self):
|
|
||||||
return self._keys[:]
|
|
||||||
|
|
||||||
def popitem(self):
|
|
||||||
try:
|
|
||||||
key = self._keys[-1]
|
|
||||||
except IndexError:
|
|
||||||
raise KeyError('dictionary is empty')
|
|
||||||
|
|
||||||
val = self[key]
|
|
||||||
del self[key]
|
|
||||||
|
|
||||||
return (key, val)
|
|
||||||
|
|
||||||
def setdefault(self, key, failobj=None):
|
|
||||||
if key not in self._keys:
|
|
||||||
self._keys.append(key)
|
|
||||||
dict.setdefault(self, key, failobj)
|
|
||||||
|
|
||||||
def update(self, d):
|
|
||||||
for key, item in d.items():
|
|
||||||
self.__setitem__(key, item)
|
|
||||||
|
|
||||||
def values(self):
|
|
||||||
return map(self.get, self._keys)
|
|
Loading…
Reference in New Issue