From: Frank Brehm Date: Mon, 16 Nov 2020 13:41:00 +0000 (+0100) Subject: Adding method __copy__() to CaseInsensitiveDict X-Git-Url: https://git.uhu-banane.org/?a=commitdiff_plain;h=9168fd65577bc80733f57c9db6a87d3d6e0c6ef3;p=pixelpark%2Fldap-migration.git Adding method __copy__() to CaseInsensitiveDict --- diff --git a/lib/ldap_migration/idict.py b/lib/ldap_migration/idict.py index e162e37..114c1d0 100644 --- a/lib/ldap_migration/idict.py +++ b/lib/ldap_migration/idict.py @@ -24,7 +24,7 @@ from fb_tools.common import pp from fb_tools.errors import FbError from fb_tools.obj import FbBaseObject -__version__ = '0.1.1' +__version__ = '0.1.2' LOG = logging.getLogger(__name__) @@ -312,13 +312,22 @@ class CaseInsensitiveDict(MutableMapping): res = {} for key in self._map.keys(): value = self._map[key] - if isinstance(value, FbBaseObject): + if isinstance(value, [FbBaseObject, CaseInsensitiveDict]): res[key] = value.as_dict(short=short) else: res[key] = copy.copy(value) return res + # ------------------------------------------------------------------------- + def __copy__(self): + + new_dict = self.__class__() + for key in self._map.keys(): + new_dict[key] = copy.copy(self._map[key]) + + return new_dict + # ------------------------------------------------------------------------- def set_key(self, key, *args):