Exemple #1
0
 def get_data(self, entry, metadata):
     if self.template is None:
         raise PluginExecutionError("Failed to load template %s" %
                                    self.name)
     return self.template.render(
         get_template_data(entry, metadata, self.name,
                           default=DefaultJinja2DataProvider()))
    def get_data(self, entry, metadata):
        if self.template is None:
            raise PluginExecutionError("Failed to load template %s" %
                                       self.name)

        stream = self.template.generate(
            **get_template_data(
                entry, metadata, self.name,
                default=DefaultGenshiDataProvider())).filter(removecomment)
        try:
            try:
                return stream.render('text',
                                     encoding=Bcfg2.Options.setup.encoding,
                                     strip_whitespace=False)
            except TypeError:
                return stream.render('text',
                                     encoding=Bcfg2.Options.setup.encoding)
        except UndefinedError:
            # a failure in a genshi expression _other_ than %{ python ... %}
            err = sys.exc_info()[1]
            stack = traceback.extract_tb(sys.exc_info()[2])
            for quad in stack:
                if quad[0] == self.name:
                    raise PluginExecutionError("%s: %s at '%s'" %
                                               (err.__class__.__name__, err,
                                                quad[2]))
            raise
        except:
            self._handle_genshi_exception(sys.exc_info())
Exemple #3
0
    def get_data(self, entry, metadata):
        if self.template is None:
            raise PluginExecutionError("Failed to load template %s" %
                                       self.name)

        stream = self.template.generate(**get_template_data(
            entry, metadata, self.name,
            default=DefaultGenshiDataProvider())).filter(removecomment)
        try:
            try:
                return stream.render('text',
                                     encoding=Bcfg2.Options.setup.encoding,
                                     strip_whitespace=False)
            except TypeError:
                return stream.render('text',
                                     encoding=Bcfg2.Options.setup.encoding)
        except UndefinedError:
            # a failure in a genshi expression _other_ than %{ python ... %}
            err = sys.exc_info()[1]
            stack = traceback.extract_tb(sys.exc_info()[2])
            for quad in stack:
                if quad[0] == self.name:
                    raise PluginExecutionError(
                        "%s: %s at '%s'" %
                        (err.__class__.__name__, err, quad[2]))
            raise
        except:
            self._handle_genshi_exception(sys.exc_info())
Exemple #4
0
 def get_data(self, entry, metadata):
     template = Template(self.data.decode(Bcfg2.Options.setup.encoding))
     return template.render(
         get_template_data(entry,
                           metadata,
                           self.name,
                           default=DefaultJinja2DataProvider()))
 def get_data(self, entry, metadata):
     template = Template(self.data.decode(Bcfg2.Options.setup.encoding),
                         compilerSettings=self.settings)
     for key, val in get_template_data(
         entry, metadata, self.name,
         default=DefaultCheetahDataProvider()).items():
         setattr(template, key, val)
     return template.respond()
Exemple #6
0
 def get_data(self, entry, metadata):
     template = Template(self.data.decode(Bcfg2.Options.setup.encoding),
                         compilerSettings=self.settings)
     for key, val in get_template_data(
             entry, metadata, self.name,
             default=DefaultCheetahDataProvider()).items():
         setattr(template, key, val)
     return template.respond()
Exemple #7
0
 def get_data(self, entry, metadata):
     if self.template is None:
         raise PluginExecutionError("Failed to load template %s" %
                                    self.name)
     return self.template.render(
         get_template_data(entry,
                           metadata,
                           self.name,
                           default=DefaultJinja2DataProvider()))
 def get_data(self, entry, metadata):
     template = Template(self.data.decode(Bcfg2.Options.setup.encoding))
     return template.render(
         get_template_data(entry, metadata, self.name,
                           default=DefaultJinja2DataProvider()))