Implement LicenseManager.__deepcopy__().
authorZac Medico <zmedico@gentoo.org>
Tue, 24 Aug 2010 18:18:36 +0000 (11:18 -0700)
committerZac Medico <zmedico@gentoo.org>
Tue, 24 Aug 2010 18:18:36 +0000 (11:18 -0700)
pym/portage/package/ebuild/_config/LicenseManager.py
pym/portage/package/ebuild/config.py

index 1c74d9cdd48ee24ce5a2b9761541ee7fc3fa2e0c..6350a33432197d37ab40933cc33420ce6c84ad09 100644 (file)
@@ -5,7 +5,7 @@ __all__ = (
        'LicenseManager',
 )
 
-import copy
+from copy import deepcopy
 
 from portage import os
 from portage.dep import ExtendedAtomDict, use_reduce
@@ -19,19 +19,24 @@ from portage.package.ebuild._config.helper import ordered_by_atom_specificity
 
 class LicenseManager(object):
 
-       def __init__(self, clone=None):
-               if clone:
-                       self._accept_license_str = copy.deepcopy(clone._accept_license_str)
-                       self._accept_license = copy.deepcopy(clone._accept_license)
-                       self._plicensedict = copy.deepcopy(clone._plicensedict)
-                       self._license_groups = copy.deepcopy(clone._license_groups)
-                       self._undef_lic_groups = copy.deepcopy(clone._undef_lic_groups)
-               else:
-                       self._accept_license_str = None
-                       self._accept_license = None
-                       self._license_groups = {}
-                       self._plicensedict = ExtendedAtomDict(dict)
-                       self._undef_lic_groups = set()
+       def __init__(self):
+               self._accept_license_str = None
+               self._accept_license = None
+               self._license_groups = {}
+               self._plicensedict = ExtendedAtomDict(dict)
+               self._undef_lic_groups = set()
+
+       def __deepcopy__(self, memo=None):
+               if memo is None:
+                       memo = {}
+               result = self.__class__()
+               memo[id(self)] = result
+               result._accept_license_str = deepcopy(self._accept_license_str, memo)
+               result._accept_license = deepcopy(self._accept_license, memo)
+               result._plicensedict = deepcopy(self._plicensedict, memo)
+               result._license_groups = deepcopy(self._license_groups, memo)
+               result._undef_lic_groups = deepcopy(self._undef_lic_groups, memo)
+               return result
 
        def read_config_files(self, abs_user_config):
                licdict = grabdict_package(os.path.join(
index a031314bf3eaf8ce1af8167840fb62f9fda7ac16..8bea4af985be099e6b0889252daf58369c64d59a 100644 (file)
@@ -458,7 +458,7 @@ class config(object):
                        self.features._features = copy.deepcopy(clone.features._features)
                        self._features_overrides = copy.deepcopy(clone._features_overrides)
 
-                       self._license_manager = LicenseManager(clone._license_manager)
+                       self._license_manager = copy.deepcopy(clone._license_manager)
                        self._accept_properties = copy.deepcopy(clone._accept_properties)
                        self._ppropertiesdict = copy.deepcopy(clone._ppropertiesdict)
                        self._penvdict = copy.deepcopy(clone._penvdict)