From: W. Trevor King Date: Tue, 7 Jun 2011 18:01:15 +0000 (-0400) Subject: Initialize `overlay` with the name of the repo, not the path. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=3ead21955cca6fcf642dbaa070f8dcf7ed215dfa;p=g-pypi.git Initialize `overlay` with the name of the repo, not the path. --- diff --git a/g_pypi/config.py b/g_pypi/config.py index 6c4beda..01f263e 100644 --- a/g_pypi/config.py +++ b/g_pypi/config.py @@ -19,7 +19,7 @@ import os 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' @@ -49,7 +49,7 @@ def setup_config(cls=None): 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()]) diff --git a/g_pypi/portage_utils.py b/g_pypi/portage_utils.py index 77001e7..b0c3eab 100644 --- a/g_pypi/portage_utils.py +++ b/g_pypi/portage_utils.py @@ -52,6 +52,16 @@ LOGGER = logging.getLogger('g-pypi') #_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(): """ @@ -66,12 +76,9 @@ 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):