def __init__(self, configfile): """ Constructor. """ BaseObject.__init__(self) self.name("OA") self.version("1.0") # Build configuration self.config = Configuration(configfile) # Create analyzer self.analyzer = Analyzer(self.config) # Default output function self.outfunc = lambda data, params: data # Load output function try: # Import module __import__(self.config.output["oa"]["module"]) # Create object outclass = getattr(sys.modules[self.config.output["oa"]["module"]], self.config.output["oa"]["class"]) self.out = outclass(self.config.output["oa"]["parameters"]) self.outfunc = self.out.output except Exception as e: self.logger.error("[%s] Error loading the output function (Error: %s)", self.name(), e, exc_info=True)
class OA(BaseObject): """ Implement the main OA processing """ def __init__(self, configfile): """ Constructor. """ BaseObject.__init__(self) self.name("OA") self.version("1.0") # Build configuration self.config = Configuration(configfile) # Create analyzer self.analyzer = Analyzer(self.config) # Default output function self.outfunc = lambda data, params: data # Load output function try: # Import module __import__(self.config.output["oa"]["module"]) # Create object outclass = getattr(sys.modules[self.config.output["oa"]["module"]], self.config.output["oa"]["class"]) self.out = outclass(self.config.output["oa"]["parameters"]) self.outfunc = self.out.output except Exception as e: self.logger.error("[%s] Error loading the output function (Error: %s)", self.name(), e, exc_info=True) def process(self, filename): """ Take as input an HDF5 file name and return the preprocessed data. """ data = self.analyzer.analyze(filename) # Purge from data all the raw data for k in tuple(data.keys()): if data[k].classtype() == "Raw": del data[k] # Output function parameters params = {"filename": filename} # Run output function return self.outfunc(data, params)