Пример #1
0
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
Пример #2
0
    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))
Пример #3
0
    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)
Пример #4
0
    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
Пример #5
0
    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())
Пример #6
0
 def setUp(self):
     self.source = SourceFactory()
Пример #7
0
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