• Login
  • Help/Guide
  • About Trac
  • Preferences
  • Wiki
  • Timeline
  • Roadmap
  • Browse Source
  • View Tickets
  • Search

Context Navigation

  • ← Previous Change
  • Next Change →

Changeset 92 for Xml/Validator/Backend/OmeValidator.py

Show
Ignore:
Timestamp:
09/14/07 11:07:40 (14 months ago)
Author:
andrew
Message:

Added tiff checks and code from web validator to load schema based on config file.

Files:
1 modified

  • Xml/Validator/Backend/OmeValidator.py (modified) (10 diffs)

Legend:

Unmodified
Added
Removed
  • Xml/Validator/Backend/OmeValidator.py

    r91 r92  
    2525from stat import * 
    2626 
     27""" 
     28# Load schemas from configured directory  
     29import cherrypy 
     30# LocalDir for schemas 
     31SCHEMA_DIR = cherrypy.config.get("validator.schema", os.path.join(os.getcwd(),"schema")) 
     32def schemaFilePath(inFilename): 
     33        return os.path.join(os.getcwd(), SCHEMA_DIR, inFilename) 
     34""" 
     35# Load schemas from current directory  
     36def schemaFilePath(inFilename): 
     37        return inFilename 
     38 
    2739# Try to load Image for XML Schema Vlaidation Support 
    2840haveTiffSupport = True 
    … …  
    161173                # build the blank dom 
    162174                self.theDom = None 
    163          
    164175         
    165176        def __str__(self): 
    … …  
    212223                self.validateAgainstSchema() 
    213224                 
     225                if len(self.unresolvedList) is not 0 : 
     226                        self.hasUnresolvableIds = True 
     227                 
    214228                if self.isXsdValid is True and len(self.errorList) is 0 : 
    215229                        self.isOmeXml = True 
    … …  
    257271                # loading the OME schema to validate against 
    258272                try: 
    259                         schema = etree.XMLSchema(etree.parse(theSchemaFile)) 
     273                        schema = etree.XMLSchema(etree.parse(schemaFilePath(theSchemaFile))) 
    260274                except: 
    261275                        #chosen scema failed to laod 
    … …  
    277291                try: 
    278292                        sax.parse(inFile, handlerContent, handlerError) 
     293                        self.hasCustomAttributes = handlerContent.hasCustomAttributes; 
    279294                except  sax.SAXParseException: 
    280295                        self.errorList.append(ParseMessage(None, None, None, "XmlError",None, "Parsing of XML failed")) 
    … …  
    375390                                        # create a file object to represent the xml string 
    376391                                        theFileString = StringIO(theXml) 
    377                                         # print theXml 
    378                                          
    379392                                        # parse the new string/file object into the report and validate it  
    380393                                        theTiffReport.parse(theFileString) 
    381394                                        theTiffReport.validateTiffImageData(image) 
    382395                                        """ 
     396                                        # print theXml 
    383397                                        print "Tiff Frames    : %s" % theTiffReport.tiffFileFrames       
    384398                                        print "Ome Frames     : %s" % theTiffReport.omeTiffDataCount     
    … …  
    486500                self.omeTiffDataPlaneCount = 0 
    487501                self.theAllFrameCount = 0 
     502                self.hasCustomAttributes = False 
    488503                 
    489504                # Setup the DOM chunk 
    … …  
    511526                                except KeyError: 
    512527                                        self.theNamespace = "" 
     528                         
     529                # save the ID in any elements encountered 
     530                if name[-16:] == "CustomAttributes": 
     531                        self.hasCustomAttributes = True 
    513532                         
    514533                # save the ID in any elements encountered 
    … …  
    570589                if name[-8:] == "TiffData": 
    571590                        self.omeTiffDataCount = self.omeTiffDataCount + 1 
    572                         # omeTiffDataPlaneCount 
     591                        # record the number of planes used by the TiffData block 
    573592                        if "NumPlanes" in attribs: 
    574593                                # use the number of planes specified 
    … …  
    685704 
    686705if __name__ == '__main__': 
    687         """     for aFilename in ["samples/completesamplenopre.xml","samples/completesample.xml","samples/completesamplenoenc.xml", 
     706        for aFilename in ["samples/completesamplenopre.xml","samples/completesample.xml","samples/completesamplenoenc.xml", 
    688707                        "samples/sdub.ome", "samples/sdub-fix.ome", "samples/sdub-fix-pre.ome",  
    689708                        "samples/tiny.ome", "samples/broke.ome"]: 
    690709                        print "============ XML file %s ============ " % aFilename 
    691710                        print XmlReport.validateFile(aFilename) 
    692         """ 
     711         
    693712         
    694713        for aFilename in ["samples/4d2wOME.tif", "samples/4d2wOME-fixed.tif", 

Download in other formats:

  • Unified Diff
  • Zip Archive

Trac Powered

Powered by Trac 0.11
By Edgewall Software.

Visit the Trac open source project at
http://trac.edgewall.org/