You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gump.apache.org by bo...@apache.org on 2009/02/11 06:37:54 UTC

svn commit: r743237 - /gump/trunk/python/gump/core/model/repository.py

Author: bodewig
Date: Wed Feb 11 05:37:52 2009
New Revision: 743237

URL: http://svn.apache.org/viewvc?rev=743237&view=rev
Log:
simplify repository parser

Modified:
    gump/trunk/python/gump/core/model/repository.py

Modified: gump/trunk/python/gump/core/model/repository.py
URL: http://svn.apache.org/viewvc/gump/trunk/python/gump/core/model/repository.py?rev=743237&r1=743236&r2=743237&view=diff
==============================================================================
--- gump/trunk/python/gump/core/model/repository.py (original)
+++ gump/trunk/python/gump/core/model/repository.py Wed Feb 11 05:37:52 2009
@@ -38,10 +38,17 @@
             
         self.url=None
         
+        typeToLabel = {'cvs':'CVS', 'svn':'Subversion', 'artifact':'Artifact',
+                       'p4':'Perforce', 'git':'Git'}
+
         type=self.getDomAttributeValue('type')
         
+        try:
+            self.type = typeToLabel[type]
+        except:
+            raise RuntimeError, 'Invalid Repository Type:' + str(xml.type)         
+
         if 'cvs'==type:
-            self.type='CVS'    
             self.web=self.getDomChildValue('cvsweb') or \
                         self.getDomChildValue('web')
             if self.hasDomChild('root'):
@@ -52,40 +59,24 @@
                 self.path=getDomChildValue(root,'path')
                 self.hostname=getDomChildValue(root,'hostname')
             else:
-                raise RuntimeError, 'No XML <root on repository: ' + self.getName()
-        elif 'svn'==type:  
-            self.type='Subversion'
-            if self.hasDomChild('url'):
-                self.url=self.getDomChildValue('url')
-            else:
-                raise RuntimeError, 'No URL on SVN repository: ' + self.getName()
-            self.web=self.getDomChildValue('web')
-            self.user=self.getDomChildValue('user')            
-            self.password=self.getDomChildValue('password')
-        elif 'artifact'==type:
-            self.type='Artifacts'
-            if self.hasDomChild('url'):
-                self.url=self.getDomChildValue('url')
-            else:
-                raise RuntimeError, 'No URL on Jars repository: ' + self.getName()                
-            self.web=self.getDomChildValue('web')
+                raise RuntimeError, 'No XML <root on repository: ' \
+                    + self.getName()
         elif 'p4'==type:
-            self.type='Perforce'
             if self.hasDomChild('root'):
                 root=self.getDomChild('root')
                 self.p4port=getDomChildValue(root,'hostname')
             else:
                 raise RuntimeError, 'No Perforce server on P4 repository: ' + self.getName()
             self.web=self.getDomChildValue('web')
-        elif 'git'==type:  
-            self.type='Git'
+        else:
             if self.hasDomChild('url'):
                 self.url=self.getDomChildValue('url')
             else:
-                raise RuntimeError, 'No URL on GIT repository: ' + self.getName()
+                raise RuntimeError, 'No URL on ' + self.type + ' repository: ' \
+                    + self.getName()
             self.web=self.getDomChildValue('web')
-        else:
-            raise RuntimeError, 'Invalid Repository Type:' + str(xml.type)         
+            self.user=self.getDomChildValue('user')            
+            self.password=self.getDomChildValue('password')
             
         # Modules referencing this repository
         self.modules=[]