From 3cfb2bc711d820fcef376aee170de560d8195819 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Fri, 28 Oct 2011 21:17:11 -0700 Subject: Deprecate unused 'virtual' constructor parameters --- pym/portage/dbapi/bintree.py | 9 ++++++++- pym/portage/dbapi/porttree.py | 18 ++++++++++++++++-- pym/portage/dbapi/vartree.py | 8 +++++++- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py index 0fb8be9c5..4c2492990 100644 --- a/pym/portage/dbapi/bintree.py +++ b/pym/portage/dbapi/bintree.py @@ -243,7 +243,8 @@ def _pkgindex_cpv_map_latest_build(pkgindex): class binarytree(object): "this tree scans for a list of all packages available in PKGDIR" - def __init__(self, _unused=None, pkgdir=None, virtual=None, settings=None): + def __init__(self, _unused=None, pkgdir=None, + virtual=DeprecationWarning, settings=None): if pkgdir is None: raise TypeError("pkgdir parameter is required") @@ -258,6 +259,12 @@ class binarytree(object): "settings['ROOT'] instead.", DeprecationWarning, stacklevel=2) + if virtual is not DeprecationWarning: + warnings.warn("The 'virtual' parameter of the " + "portage.dbapi.bintree.binarytree" + " constructor is unused", + DeprecationWarning, stacklevel=2) + if True: self.pkgdir = normalize_path(pkgdir) self.dbapi = bindbapi(self, settings=settings) diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py index fc7feb3ba..5c45d97c7 100644 --- a/pym/portage/dbapi/porttree.py +++ b/pym/portage/dbapi/porttree.py @@ -1064,7 +1064,7 @@ def close_portdbapi_caches(): portage.process.atexit_register(portage.portageexit) class portagetree(object): - def __init__(self, root=None, virtual=None, settings=None): + def __init__(self, root=None, virtual=DeprecationWarning, settings=None): """ Constructor for a PortageTree @@ -1087,8 +1087,14 @@ class portagetree(object): "settings['ROOT'] instead.", DeprecationWarning, stacklevel=2) + if virtual is not DeprecationWarning: + warnings.warn("The 'virtual' parameter of the " + "portage.dbapi.porttree.portagetree" + " constructor is unused", + DeprecationWarning, stacklevel=2) + self.portroot = settings["PORTDIR"] - self.virtual = virtual + self.__virtual = virtual self.dbapi = portdbapi(mysettings=settings) @property @@ -1100,6 +1106,14 @@ class portagetree(object): DeprecationWarning, stacklevel=3) return self.settings['ROOT'] + @property + def virtual(self): + warnings.warn("The 'virtual' attribute of " + \ + "portage.dbapi.porttree.portagetree" + \ + " is deprecated.", + DeprecationWarning, stacklevel=3) + return self.__virtual + def dep_bestmatch(self,mydep): "compatibility method" mymatch = self.dbapi.xmatch("bestmatch-visible",mydep) diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index e71906252..ee0db6f24 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -1163,7 +1163,7 @@ class vardbapi(dbapi): class vartree(object): "this tree will scan a var/db/pkg database located at root (passed to init)" - def __init__(self, root=None, virtual=None, categories=None, + def __init__(self, root=None, virtual=DeprecationWarning, categories=None, settings=None): if settings is None: @@ -1176,6 +1176,12 @@ class vartree(object): "settings['ROOT'] instead.", DeprecationWarning, stacklevel=2) + if virtual is not DeprecationWarning: + warnings.warn("The 'virtual' parameter of the " + "portage.dbapi.vartree.vartree" + " constructor is unused", + DeprecationWarning, stacklevel=2) + self.settings = settings self.dbapi = vardbapi(settings=settings, vartree=self) self.populated = 1 -- cgit v1.2.3-1-g7c22