[Yum-devel] patch to make duplicate repos easier to catch

Chris Lumens clumens at redhat.com
Wed Aug 23 16:57:29 UTC 2006


In the anaconda UI to add extra repos, it'd be easier to catch the case
when a duplicate repo has been added.  Right now, you have to catch the
all-purpose RepoError and examine the contents of the message in the
exception.  Yuck.  Here's a patch to make this nicer.  Note that I'm
subclassing RepoError so nobody else has to change their code if they
don't want to.

- Chris


Index: yum/Errors.py
===================================================================
RCS file: /cvsroot/yum/cvs/yum/yum/Errors.py,v
retrieving revision 1.8
diff -u -r1.8 Errors.py
--- yum/Errors.py	28 May 2006 05:32:49 -0000	1.8
+++ yum/Errors.py	23 Aug 2006 16:18:12 -0000
@@ -40,6 +40,11 @@
         YumBaseError.__init__(self)
         self.args = args
 
+class DuplicateRepoError(RepoError):
+    def __init__(self, args=None):
+        RepoError.__init__(self)
+        self.args = args
+
 class ConfigError(YumBaseError):
     def __init__(self, args=None):
         YumBaseError.__init__(self)
Index: yum/repos.py
===================================================================
RCS file: /cvsroot/yum/cvs/yum/yum/repos.py,v
retrieving revision 1.96
diff -u -r1.96 repos.py
--- yum/repos.py	1 Jul 2006 16:31:14 -0000	1.96
+++ yum/repos.py	23 Aug 2006 16:18:13 -0000
@@ -45,7 +45,7 @@
 
     def add(self, repoobj):
         if self.repos.has_key(repoobj.id):
-            raise Errors.RepoError, 'Repository %s is listed more than once in the configuration' % (repoobj.id)
+            raise Errors.DuplicateRepoError, 'Repository %s is listed more than once in the configuration' % (repoobj.id)
         self.repos[repoobj.id] = repoobj
         
 



More information about the Yum-devel mailing list