gump-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aj...@apache.org
Subject svn commit: rev 54092 - gump/trunk/python/gump/loader
Date Fri, 08 Oct 2004 15:20:13 GMT
Author: ajack
Date: Fri Oct  8 08:20:13 2004
New Revision: 54092

Modified:
   gump/trunk/python/gump/loader/loader.py
Log:
Report on XML parse failures (at least to warning in logs)

Modified: gump/trunk/python/gump/loader/loader.py
==============================================================================
--- gump/trunk/python/gump/loader/loader.py	(original)
+++ gump/trunk/python/gump/loader/loader.py	Fri Oct  8 08:20:13 2004
@@ -123,6 +123,9 @@
     def getBaseDir(self):
         return self.basedir
         
+    def getDescription(self):
+        return self.tag
+        
 class XmlUrlTask(XmlTask):
     def __init__(self,tag,url,basedir=None):
         XmlTask.__init__(self,url,tag,basedir)
@@ -131,6 +134,9 @@
     def getLocation(self): return self.getUrl()
     def getUrl(self):
         return self.url
+        
+    def getDescription(self):
+        return '%s @ %s' % (self.tag, self.url)
                 
 class XmlFileTask(XmlTask):
     def __init__(self,tag,file,basedir=None):
@@ -141,6 +147,9 @@
     def getFile(self):
         return self.file
         
+    def getDescription(self):
+        return '%s @ %s' % (self.tag, self.file)
+        
 class XmlWorker:   
 
     def __init__(self):
@@ -161,6 +170,9 @@
             
             task.setResult(XmlResult(dom))
         except Exception, details:
+            
+            log.warning('Failed to parse XML %s : %s' % (task.getDescription(),details))
+            
             task.setFailed(str(details))
       
     def postProcess(self,task,dom):        
@@ -188,6 +200,9 @@
                 log.debug("Skip Node: " + `child.nodeType` + ' ' + `child`)             
         
     
 class ModelLoader:
+    """
+    Load some XML, and map that to a model.
+    """
     def __init__(self,cache=False):
         self.annotations=[]
         self.xmlloader=XmlLoader(cache)
@@ -207,6 +222,9 @@
         return self.postProcess(cls)
         
     def postProcess(self,cls):
+        """
+        Convert the XML (DOM) into a class.
+        """
         
         rootObject=None
         
@@ -257,6 +275,9 @@
         # Copy over any XML errors/warnings
         #if isinstance(object,Annotatable):
         #    transferAnnotations(parser, object)
+        
+        if not rootObject:
+            raise RuntimeError, 'Failed to extract %s from XML.' % cls.__name__
         
         return rootObject
         

Mime
View raw message