[Python 3]: Migration for UserDict.DictMixins for Python 3.

This commit is contained in:
Dorian 2013-10-24 18:26:02 -04:00
parent cc2dd9c0f4
commit 5a9fc81ad9
1 changed files with 6 additions and 3 deletions

View File

@ -23,7 +23,10 @@ L{HostKeys}
import base64 import base64
import binascii import binascii
from Crypto.Hash import SHA, HMAC from Crypto.Hash import SHA, HMAC
import UserDict try:
from UserDict import DictMixin
except ImportError:
from collections import MutableMapping as DictMixin
from paramiko.common import * from paramiko.common import *
from paramiko.dsskey import DSSKey from paramiko.dsskey import DSSKey
@ -105,7 +108,7 @@ class HostKeyEntry:
return '<HostKeyEntry %r: %r>' % (self.hostnames, self.key) return '<HostKeyEntry %r: %r>' % (self.hostnames, self.key)
class HostKeys (UserDict.DictMixin): class HostKeys (DictMixin):
""" """
Representation of an openssh-style "known hosts" file. Host keys can be Representation of an openssh-style "known hosts" file. Host keys can be
read from one or more files, and then individual hosts can be looked up to read from one or more files, and then individual hosts can be looked up to
@ -211,7 +214,7 @@ class HostKeys (UserDict.DictMixin):
@return: keys associated with this host (or C{None}) @return: keys associated with this host (or C{None})
@rtype: dict(str, L{PKey}) @rtype: dict(str, L{PKey})
""" """
class SubDict (UserDict.DictMixin): class SubDict (DictMixin):
def __init__(self, hostname, entries, hostkeys): def __init__(self, hostname, entries, hostkeys):
self._hostname = hostname self._hostname = hostname
self._entries = entries self._entries = entries