import logging
from logging.config import fileConfig
-from g_pypi.portage_utils import get_keyword, get_portdir_overlay
+from g_pypi.portage_utils import get_keyword, get_portdir_overlay, get_repo_name
__docformat__ = 'restructuredtext'
config.set('options', 'background', 'dark')
config.add_section('core')
config.set('core', 'keyword', get_keyword())
- config.set('core', 'overlay', get_portdir_overlay())
+ config.set('core', 'overlay', get_repo_name(get_portdir_overlay()))
config.set('core', 'overlay_path', '')
config.set('core', 'format', 'ansi')
config.read([get_rc_filename()])
#_L.setLevel(LOGGER.logging.DEBUG)
#LOGGER.addHandler(logging.StreamHandler())
+def get_repo_name(path):
+ """Return the name of the overlay rooted at `path`.
+
+ @returns: string overlay name
+ """
+ repo_name_path = os.path.join(path, 'profiles/repo_name')
+ try:
+ return open(repo_name_path, 'r').readline().strip()
+ except (OSError,IOError):
+ LOGGER.warn("no profiles/repo_name in %s" % path)
def get_repo_names():
"""
[os.path.realpath(t) for t in ENV["PORTDIR_OVERLAY"].split()]
treemap = {}
for path in porttrees:
- repo_name_path = os.path.join(path, 'profiles/repo_name')
- try:
- repo_name = open(repo_name_path, 'r').readline().strip()
- treemap[repo_name] = path
- except (OSError,IOError):
- LOGGER.warn("No repo_name in %s" % path)
+ name = get_repo_name(path)
+ if name:
+ treemap[name] = path
return treemap
def get_installed_ver(cpn):