Пример #1
0
 def __init__(self, file, config, baseline):
     AlertHandler.__init__(self, file, config, baseline)
     docFactory = DocumentFactory()
     self.saxReader = SAXReader(docFactory)
     self.xmlMapFile = StrSubstitutor.replaceSystemProperties(config['xmlMap'])
     if not os.path.exists(self.xmlMapFile):
         raise AlertException("Requested xmlMap file %s does not exist." % self.xmlMapFile)
     
     ## Make sure we can see our mappings
     inStream = FileInputStream(File(self.xmlMapFile))
     xmlMappings = JsonSimple(inStream)
     self.map = xmlMappings.getObject(["mappings"])
     self.exceptions = xmlMappings.getObject(["exceptions"])
     self.defaultNamespace = xmlMappings.getObject(["defaultNamespace"])
     
     self.mappedExceptionCount = 0
Пример #2
0
    def __init__(self, file, config, baseline):
        AlertHandler.__init__(self, file, config, baseline)
        docFactory = DocumentFactory()
        self.saxReader = SAXReader(docFactory)
        self.xmlMapFile = StrSubstitutor.replaceSystemProperties(
            config['xmlMap'])
        if not os.path.exists(self.xmlMapFile):
            raise AlertException("Requested xmlMap file %s does not exist." %
                                 self.xmlMapFile)

        ## Make sure we can see our mappings
        inStream = FileInputStream(File(self.xmlMapFile))
        xmlMappings = JsonSimple(inStream)
        self.map = xmlMappings.getObject(["mappings"])
        self.exceptions = xmlMappings.getObject(["exceptions"])
        self.defaultNamespace = xmlMappings.getObject(["defaultNamespace"])

        self.mappedExceptionCount = 0
Пример #3
0
    def __init__(self, file, config, baseline):
        AlertHandler.__init__(self, file, config, baseline)
        
        if not 'fieldMap' in config:
            raise AlertException("No FieldMap was provided for the CSVAlertHandler")
        else:
            self.fieldMap = config['fieldMap']
        
        #self.headerRow = True  
        
        self.dialect = "local"
        if 'DialectClass' in config:
            self.dialect = config['DialectClass']
        elif 'Dialect' in config:
            csv.register_dialect("local", LocalDialect(config['Dialect']))
        else:
            csv.register_dialect("local", LocalDialect({}))

        self.multiValue = False
        self.multiValueFields = None
        self.multiValueDelimiter = ";"
        
        if "multiValue" in config:
            if "fields" in config["multiValue"]:
                self.multiValueFields = config["multiValue"]["fields"]
                for field in self.multiValueFields:
                    if field not in self.fieldMap:
                        raise AlertException("The requested multiValue field [%s] was not provided in the FieldMap." % field)
            else:
                raise AlertException("The multiValue option must contain a fields key.")
            if "fieldDelimiter" in config["multiValue"]:
                self.multiValueDelimiter = config["multiValue"]["fieldDelimiter"]
            else:
                raise AlertException("The multiValue option must contain a fieldDelimiter key.")
            
            self.multiValue = True
            
        if "scriptHandlers" in config:
            self.scriptHandlers = config["scriptHandlers"]
        else:
            self.scriptHandlers = {}