From 567700e7cc0aa2ddb73128c9b02ffbeeefcf74e6 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Fri, 20 Aug 2010 06:43:16 -0700 Subject: [PATCH] Make the portagetree.root attribute a property that generates a DeprecationWarning on access. --- pym/portage/dbapi/porttree.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py index c925d9bf8..a604260b2 100644 --- a/pym/portage/dbapi/porttree.py +++ b/pym/portage/dbapi/porttree.py @@ -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) -- 2.26.2