Make the portagetree.root attribute a property that generates a
authorZac Medico <zmedico@gentoo.org>
Fri, 20 Aug 2010 13:43:16 +0000 (06:43 -0700)
committerZac Medico <zmedico@gentoo.org>
Fri, 20 Aug 2010 13:43:16 +0000 (06:43 -0700)
DeprecationWarning on access.

pym/portage/dbapi/porttree.py

index c925d9bf8ec92d6d8b4daa0a8b92795b536b2b1c..a604260b28960fb8cfd19cfd09db9b0c9d9739d0 100644 (file)
@@ -1060,7 +1060,7 @@ class portagetree(object):
                """
                Constructor for a PortageTree
                
-               @param root: ${ROOT}, defaults to '/', see make.conf(5)
+               @param root: deprectated, defaults to settings['ROOT']
                @type root: String/Path
                @param virtual: UNUSED
                @type virtual: No Idea
@@ -1072,8 +1072,7 @@ class portagetree(object):
                        settings = portage.settings
                self.settings = settings
 
-               self.root = settings['ROOT']
-               if root is not None and root != self.root:
+               if root is not None and root != settings['ROOT']:
                        warnings.warn("The root parameter of the " + \
                                "portage.dbapi.porttree.portagetree" + \
                                " constructor is now unused. Use " + \
@@ -1084,6 +1083,15 @@ class portagetree(object):
                self.virtual = virtual
                self.dbapi = portdbapi(mysettings=settings)
 
+       @property
+       def root(self):
+               warnings.warn("The root attribute of " + \
+                       "portage.dbapi.porttree.portagetree" + \
+                       " is deprecated. Use " + \
+                       "settings['ROOT'] instead.",
+                       DeprecationWarning, stacklevel=2)
+               return self.settings['ROOT']
+
        def dep_bestmatch(self,mydep):
                "compatibility method"
                mymatch = self.dbapi.xmatch("bestmatch-visible",mydep)