Initialize `overlay` with the name of the repo, not the path.
authorW. Trevor King <wking@drexel.edu>
Tue, 7 Jun 2011 18:01:15 +0000 (14:01 -0400)
committerW. Trevor King <wking@drexel.edu>
Tue, 7 Jun 2011 18:01:15 +0000 (14:01 -0400)
g_pypi/config.py
g_pypi/portage_utils.py

index 6c4beda95224ceab0110b9d0af2d52c35288ca51..01f263ebe48dce2926ab22f73944f75a05bb49ae 100644 (file)
@@ -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()])
index 77001e740f083085282b8e867f3ad512daeff43a..b0c3eab69ee4260acb773374885ce4ead0f60907 100644 (file)
@@ -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):