Raise an error if the named repository doesn't exist v2.2_pre7
authorMarius Mauch <genone@gentoo.org>
Wed, 21 May 2008 16:05:03 +0000 (16:05 -0000)
committerMarius Mauch <genone@gentoo.org>
Wed, 21 May 2008 16:05:03 +0000 (16:05 -0000)
svn path=/main/trunk/; revision=10383

pym/portage/sets/files.py

index bf9f9e6e8f0245c2d8006ad9f71303fda05ff333..b03a60e9b9872e0715aa7bae1769474804cba114 100644 (file)
@@ -101,7 +101,10 @@ class StaticFileSet(EditablePackageSet):
                # look for repository path variables
                match = self._repopath_match.match(filename)
                if match:
-                       filename = self._repopath_sub.sub(trees["porttree"].dbapi.treemap[match.groupdict()["reponame"]], filename)
+                       try:
+                               filename = self._repopath_sub.sub(trees["porttree"].dbapi.treemap[match.groupdict()["reponame"]], filename)
+                       except KeyError:
+                               raise SetConfigError("Could not find repository '%s'" % match.groupdict()["reponame"])
                return StaticFileSet(filename, greedy=greedy, dbapi=trees["vartree"].dbapi)
        singleBuilder = classmethod(singleBuilder)
        
@@ -115,7 +118,10 @@ class StaticFileSet(EditablePackageSet):
                # look for repository path variables
                match = self._repopath_match.match(directory)
                if match:
-                       directory = self._repopath_sub.sub(trees["porttree"].dbapi.treemap[match.groupdict()["reponame"]], directory)
+                       try:
+                               directory = self._repopath_sub.sub(trees["porttree"].dbapi.treemap[match.groupdict()["reponame"]], directory)
+                       except KeyError:
+                               raise SetConfigError("Could not find repository '%s'" % match.groupdict()["reponame"])
                if os.path.isdir(directory):
                        for filename in os.listdir(directory):
                                if filename.endswith(".metadata"):