def when_factory_config(context): factory = SourceFactory() config = context.object_config config["input"]["locations"] = context.conf_files response = factory.create_from_config(config) context.root = response
def main(self): """Run the command """ sourceService = SourceService() sourceFactory = SourceFactory() config = self.get_config() sources = sourceFactory.create_from_config(config) sourceService.validate(sources) print(json_repr(sources))
def main(self): """Run the command """ sourceService = SourceService() sourceFactory = SourceFactory() templateFactory = TemplateFactory() config = self.get_config() sources = sourceFactory.create_from_config(config) sourceService.validate(sources) template = templateFactory.create_from_config(config) template.render(sources, config)
def _get_sources(self): now = datetime.now() try: sourceService = SourceService() sourceFactory = SourceFactory() sources = sourceFactory.create_from_config(self.config) sourceService.validate(sources) self.logger.debug("Parse sources in %s." % (datetime.now() - now)) except: if self.traceback: self.logger.exception("Failed to parse sources") else: self.logger.error("Failed to parse sources") raise return sources
def refresh_source(self, event): """Refresh sources then templates """ now = datetime.now() self.logger.info("Sources changed") sourceFactory = SourceFactory() sourceService = SourceService() templateFactory = TemplateFactory() try: self.sources = sourceFactory.create_from_config(self.config) sourceService.validate(self.sources) template = templateFactory.create_from_config(self.config) template.render(self.sources, self.config) self.logger.debug("Render in %s." % (datetime.now() - now)) except: self.logger.warning("Failed to render") self.logger.error(traceback.format_exc())
def setUp(self): self.source = SourceFactory()
def when_factory_config_directory(context): factory = SourceFactory() config = context.object_config config["input"]["locations"] = [context.temp_dir] response = factory.create_from_config(config) context.root = response