summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2007-06-13 23:35:14 +0000
committerZac Medico <zmedico@gentoo.org>2007-06-13 23:35:14 +0000
commitd13102fe56b739d836f878ba89f2cd9ac4caa3d5 (patch)
tree4c7e0bd7eb1852f06eb1051e737f72990cd89863
parent3e3bb8306f5abe86988e2ce908435fd81f2af189 (diff)
downloadportage-d13102fe56b739d836f878ba89f2cd9ac4caa3d5.tar.gz
portage-d13102fe56b739d836f878ba89f2cd9ac4caa3d5.tar.bz2
portage-d13102fe56b739d836f878ba89f2cd9ac4caa3d5.zip
Pass existing portdbapi and vardbapi instances into the NewsManager constructor.
svn path=/main/trunk/; revision=6841
-rw-r--r--pym/emerge/__init__.py18
-rw-r--r--pym/portage/news.py16
2 files changed, 18 insertions, 16 deletions
diff --git a/pym/emerge/__init__.py b/pym/emerge/__init__.py
index 06759d70b..4aabe97c3 100644
--- a/pym/emerge/__init__.py
+++ b/pym/emerge/__init__.py
@@ -3793,13 +3793,15 @@ def display_news_notification(trees):
if len(trees) > 1 and target_root != "/":
break
settings = trees[target_root]["vartree"].settings
- porttree = trees[target_root]["porttree"].dbapi
+ portdb = trees[target_root]["porttree"].dbapi
+ vardb = trees[target_root]["vartree"].dbapi
NEWS_PATH = os.path.join("metadata", "news")
UNREAD_PATH = os.path.join(target_root, NEWS_LIB_PATH, "news")
newsReaderDisplay = False
- for repo in porttree.getRepositories():
- unreadItems = checkUpdatedNewsItems(target_root, NEWS_PATH, UNREAD_PATH, repo)
+ for repo in portdb.getRepositories():
+ unreadItems = checkUpdatedNewsItems(
+ portdb, vardb, NEWS_PATH, UNREAD_PATH, repo)
if unreadItems:
if not newsReaderDisplay:
newsReaderDisplay = True
@@ -3910,13 +3912,15 @@ def chk_updated_cfg_files(target_root, config_protect):
#print " "+yellow("*")+" Type "+green("emerge --help config")+" to learn how to update config files."
print " "+yellow("*")+" Type "+green("emerge --help config")+" to learn how to update config files."
-def checkUpdatedNewsItems( root, NEWS_PATH, UNREAD_PATH, repo_id ):
+def checkUpdatedNewsItems(portdb, vardb, NEWS_PATH, UNREAD_PATH, repo_id):
"""
Examines news items in repodir + '/' + NEWS_PATH and attempts to find unread items
Returns the number of unread (yet relevent) items.
- @param root:
- @type root:
+ @param portdb: a portage tree database
+ @type portdb: pordbapi
+ @param vardb: an installed package database
+ @type vardb: vardbapi
@param NEWS_PATH:
@type NEWS_PATH:
@param UNREAD_PATH:
@@ -3929,7 +3933,7 @@ def checkUpdatedNewsItems( root, NEWS_PATH, UNREAD_PATH, repo_id ):
"""
from portage.news import NewsManager
- manager = NewsManager( root, NEWS_PATH, UNREAD_PATH )
+ manager = NewsManager(portdb, vardb, NEWS_PATH, UNREAD_PATH)
return manager.getUnreadItems( repo_id, update=True )
def is_valid_package_atom(x):
diff --git a/pym/portage/news.py b/pym/portage/news.py
index 3cfb5de12..028805876 100644
--- a/pym/portage/news.py
+++ b/pym/portage/news.py
@@ -4,7 +4,6 @@
# $Id$
from portage.const import INCREMENTALS, PROFILE_PATH, NEWS_LIB_PATH
-from portage import config, vartree, vardbapi, portdbapi
from portage.util import ensure_dirs, apply_permissions
from portage.data import portage_gid
from portage.locks import lockfile, unlockfile, lockdir, unlockdir
@@ -26,17 +25,16 @@ class NewsManager(object):
TIMESTAMP_FILE = "news-timestamp"
- def __init__(self, root, NEWS_PATH, UNREAD_PATH, LANGUAGE_ID='en'):
+ def __init__(self, portdb, vardb, NEWS_PATH, UNREAD_PATH, LANGUAGE_ID='en'):
self.NEWS_PATH = NEWS_PATH
self.UNREAD_PATH = UNREAD_PATH
- self.TIMESTAMP_PATH = os.path.join(root, NEWS_LIB_PATH, NewsManager.TIMESTAMP_FILE)
- self.target_root = root
+ self.TIMESTAMP_PATH = os.path.join(vardb.root,
+ NEWS_LIB_PATH, NewsManager.TIMESTAMP_FILE)
+ self.target_root = vardb.root
self.LANGUAGE_ID = LANGUAGE_ID
- self.config = config(config_root = os.environ.get("PORTAGE_CONFIGROOT", "/"),
- target_root = root, config_incrementals = INCREMENTALS)
- self.vdb = vardbapi(settings = self.config, root = root,
- vartree = vartree(root = root, settings = self.config))
- self.portdb = portdbapi(porttree_root = self.config["PORTDIR"], mysettings = self.config)
+ self.config = vardb.settings
+ self.vdb = vardb
+ self.portdb = portdb
# Ensure that the unread path exists and is writable.
dirmode = 02070