diff options
author | Zac Medico <zmedico@gentoo.org> | 2011-10-24 10:54:48 -0700 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2011-10-24 10:54:48 -0700 |
commit | e45a3f15379d8de4a772e1c70eee51c3d0e358a5 (patch) | |
tree | 2a77e5210448a738faa9cb8c81cd67a7387b39ac | |
parent | 47232e37f2b7f63d670de54d1a10f4c1e0dcec99 (diff) | |
download | portage-e45a3f15379d8de4a772e1c70eee51c3d0e358a5.tar.gz portage-e45a3f15379d8de4a772e1c70eee51c3d0e358a5.tar.bz2 portage-e45a3f15379d8de4a772e1c70eee51c3d0e358a5.zip |
deprecate "root" attributes
In preparation for prefix support, were EROOT will be used in place of
ROOT in many places, deprecate unnecessary "root" attributes in order
to eliminate them as a possible source of confusion.
-rw-r--r-- | pym/_emerge/BlockerDB.py | 5 | ||||
-rw-r--r-- | pym/_emerge/FakeVartree.py | 11 | ||||
-rw-r--r-- | pym/portage/dbapi/bintree.py | 28 | ||||
-rw-r--r-- | pym/portage/dbapi/vartree.py | 40 | ||||
-rw-r--r-- | pym/portage/news.py | 2 |
5 files changed, 67 insertions, 19 deletions
diff --git a/pym/_emerge/BlockerDB.py b/pym/_emerge/BlockerDB.py index 4819749e5..0033665e3 100644 --- a/pym/_emerge/BlockerDB.py +++ b/pym/_emerge/BlockerDB.py @@ -25,7 +25,7 @@ class BlockerDB(object): self._dep_check_trees = None self._fake_vartree = fake_vartree self._dep_check_trees = { - self._vartree.root : { + self._vartree.settings["ROOT"] : { "porttree" : fake_vartree, "vartree" : fake_vartree, }} @@ -36,7 +36,8 @@ class BlockerDB(object): new_pkg is planned to be installed. This ignores build-time blockers, since new_pkg is assumed to be built already. """ - blocker_cache = BlockerCache(self._vartree.root, self._vartree.dbapi) + blocker_cache = BlockerCache(self._vartree.settings["ROOT"], + self._vartree.dbapi) dep_keys = ["RDEPEND", "PDEPEND"] settings = self._vartree.settings stale_cache = set(blocker_cache) diff --git a/pym/_emerge/FakeVartree.py b/pym/_emerge/FakeVartree.py index ddec7c504..a2b923248 100644 --- a/pym/_emerge/FakeVartree.py +++ b/pym/_emerge/FakeVartree.py @@ -2,6 +2,7 @@ # Distributed under the terms of the GNU General Public License v2 import sys +import warnings import portage from portage import os @@ -49,7 +50,6 @@ class FakeVartree(vartree): real_vartree = root_config.trees["vartree"] self._real_vardb = real_vartree.dbapi portdb = root_config.trees["porttree"].dbapi - self.root = real_vartree.root self.settings = real_vartree.settings mykeys = list(real_vartree.dbapi._aux_cache_keys) if "_mtime_" not in mykeys: @@ -71,6 +71,15 @@ class FakeVartree(vartree): self._portdb = portdb self._global_updates = None + @property + def root(self): + warnings.warn("The root attribute of " + "_emerge.FakeVartree.FakeVartree" + " is deprecated. Use " + "settings['ROOT'] instead.", + DeprecationWarning, stacklevel=2) + return self.settings['ROOT'] + def _match_wrapper(self, cpv, use_cache=1): """ Make sure the metadata in Package instances gets updated for any diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py index 5c091bd45..39bb030f9 100644 --- a/pym/portage/dbapi/bintree.py +++ b/pym/portage/dbapi/bintree.py @@ -41,6 +41,7 @@ import subprocess import sys import tempfile import textwrap +import warnings from itertools import chain try: from urllib.parse import urlparse @@ -242,10 +243,22 @@ 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, root, pkgdir, virtual=None, settings=None): + def __init__(self, _unused=None, pkgdir=None, virtual=None, settings=None): + + if pkgdir is None: + raise TypeError("pkgdir parameter is required") + + if settings is None: + raise TypeError("settings parameter is required") + + if _unused is not None and _unused != settings['ROOT']: + warnings.warn("The root parameter of the " + "portage.dbapi.bintree.binarytree" + " constructor is now unused. Use " + "settings['ROOT'] instead.", + DeprecationWarning, stacklevel=2) + if True: - self.root = root - #self.pkgdir=settings["PKGDIR"] self.pkgdir = normalize_path(pkgdir) self.dbapi = bindbapi(self, settings=settings) self.update_ents = self.dbapi.update_ents @@ -330,6 +343,15 @@ class binarytree(object): chain(*self._pkgindex_translated_keys) )) + @property + def root(self): + warnings.warn("The root attribute of " + "portage.dbapi.bintree.binarytree" + " is deprecated. Use " + "settings['ROOT'] instead.", + DeprecationWarning, stacklevel=2) + return self.settings['ROOT'] + def move_ent(self, mylist, repo_match=None): if not self.populated: self.populate() diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index 1fc95a39b..b69b363bb 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -129,12 +129,11 @@ class vardbapi(dbapi): if settings is None: settings = portage.settings self.settings = settings - self.root = settings['ROOT'] - if _unused_param is not None and _unused_param != self.root: - warnings.warn("The first parameter of the " + \ - "portage.dbapi.vartree.vardbapi" + \ - " constructor is now unused. Use " + \ + if _unused_param is not None and _unused_param != settings['ROOT']: + warnings.warn("The first parameter of the " + "portage.dbapi.vartree.vardbapi" + " constructor is now unused. Use " "settings['ROOT'] instead.", DeprecationWarning, stacklevel=2) @@ -148,7 +147,7 @@ class vardbapi(dbapi): self._fs_lock_count = 0 if vartree is None: - vartree = portage.db[self.root]["vartree"] + vartree = portage.db[settings["ROOT"]]["vartree"] self.vartree = vartree self._aux_cache_keys = set( ["BUILD_TIME", "CHOST", "COUNTER", "DEPEND", "DESCRIPTION", @@ -164,7 +163,7 @@ class vardbapi(dbapi): self._plib_registry = None if _ENABLE_PRESERVE_LIBS: - self._plib_registry = PreservedLibsRegistry(self.root, + self._plib_registry = PreservedLibsRegistry(settings["ROOT"], os.path.join(self._eroot, PRIVATE_PATH, "preserved_libs_registry")) @@ -175,6 +174,15 @@ class vardbapi(dbapi): self._cached_counter = None + @property + def root(self): + warnings.warn("The root attribute of " + "portage.dbapi.vartree.vardbapi" + " is deprecated. Use " + "settings['ROOT'] instead.", + DeprecationWarning, stacklevel=2) + return self.settings['ROOT'] + def getpath(self, mykey, filename=None): # This is an optimized hotspot, so don't use unicode-wrapped # os module and don't use os.path.join(). @@ -1157,12 +1165,11 @@ class vartree(object): if settings is None: settings = portage.settings - self.root = settings['ROOT'] - if root is not None and root != self.root: - warnings.warn("The 'root' parameter of the " + \ - "portage.dbapi.vartree.vartree" + \ - " constructor is now unused. Use " + \ + if root is not None and root != settings['ROOT']: + warnings.warn("The 'root' parameter of the " + "portage.dbapi.vartree.vartree" + " constructor is now unused. Use " "settings['ROOT'] instead.", DeprecationWarning, stacklevel=2) @@ -1170,6 +1177,15 @@ class vartree(object): self.dbapi = vardbapi(settings=settings, vartree=self) self.populated = 1 + @property + def root(self): + warnings.warn("The root attribute of " + "portage.dbapi.vartree.vartree" + " is deprecated. Use " + "settings['ROOT'] instead.", + DeprecationWarning, stacklevel=2) + return self.settings['ROOT'] + def getpath(self, mykey, filename=None): return self.dbapi.getpath(mykey, filename=filename) diff --git a/pym/portage/news.py b/pym/portage/news.py index 031e98c8c..1bf0522a7 100644 --- a/pym/portage/news.py +++ b/pym/portage/news.py @@ -39,7 +39,7 @@ class NewsManager(object): def __init__(self, portdb, vardb, news_path, unread_path, language_id='en'): self.news_path = news_path self.unread_path = unread_path - self.target_root = vardb.root + self.target_root = vardb.settings["ROOT"] self.language_id = language_id self.config = vardb.settings self.vdb = vardb |