From 9168fd65577bc80733f57c9db6a87d3d6e0c6ef3 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Mon, 16 Nov 2020 14:41:00 +0100 Subject: [PATCH] Adding method __copy__() to CaseInsensitiveDict --- lib/ldap_migration/idict.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) 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): -- 2.39.5