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
#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:
"""
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):
# $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
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