Esempio n. 1
0
 def cook(self, body):
     PageTemplateFile.cook(self, body)
     if self.macro:
         # render only the portion of the template included in a
         # define-macro named the value of self.macro
         macro_renderer = self.macros[self.macro].include
         self._render = macro_renderer
Esempio n. 2
0
 def cook(self, body):
     PageTemplateFile.cook(self, body)
     if self.macro:
         # render only the portion of the template included in a
         # define-macro named the value of self.macro
         macro_renderer = self.macros[self.macro].include
         self._render = macro_renderer
Esempio n. 3
0
 def template(self):
     tf = PageTemplateFile(
         self.path, auto_reload=self.lookup.auto_reload, debug=self.lookup.debug, translate=self.lookup.translate
     )
     if self.macro:
         # render only the portion of the template included in a
         # define-macro named the value of self.macro
         macro_renderer = tf.macros[self.macro].include
         tf._render = macro_renderer
     return tf
Esempio n. 4
0
 def template(self):
     tf = PageTemplateFile(self.path,
                           auto_reload=self.lookup.auto_reload,
                           debug=self.lookup.debug,
                           translate=self.lookup.translate)
     if self.macro:
         # render only the portion of the template included in a
         # define-macro named the value of self.macro
         macro_renderer = tf.macros[self.macro].include
         tf._render = macro_renderer
     return tf
Esempio n. 5
0
 def template(self):
     if sys.platform.startswith("java"):  # pragma: no cover
         raise RuntimeError("Chameleon templates are not compatible with Jython")
     tf = PageTemplateFile(
         self.path, auto_reload=self.lookup.auto_reload, debug=self.lookup.debug, translate=self.lookup.translate
     )
     if self.macro:
         # render only the portion of the template included in a
         # define-macro named the value of self.macro
         macro_renderer = tf.macros[self.macro].include
         tf._render = macro_renderer
     return tf
Esempio n. 6
0
 def template(self):
     if sys.platform.startswith('java'):  # pragma: no cover
         raise RuntimeError(
             'Chameleon templates are not compatible with Jython')
     tf = PageTemplateFile(self.path,
                           auto_reload=self.lookup.auto_reload,
                           debug=self.lookup.debug,
                           translate=self.lookup.translate)
     if self.macro:
         # render only the portion of the template included in a
         # define-macro named the value of self.macro
         macro_renderer = tf.macros[self.macro].include
         tf._render = macro_renderer
     return tf
Esempio n. 7
0
 def template(self):
     if sys.platform.startswith('java'):  # pragma: no cover
         raise RuntimeError(
             'Chameleon templates are not compatible with Jython')
     return PageTemplateFile(self.path,
                             auto_reload=self.lookup.auto_reload,
                             debug=self.lookup.debug,
                             translate=self.lookup.translate)
Esempio n. 8
0
    def load(self, filename):
        for path in self.search_path:
            path = os.path.join(path, filename)
            if (path in self.notexists) and (not self.auto_reload):
                raise mako.exceptions.TopLevelLookupException(
                    "Can not find template %s" % filename)
            try:
                return PageTemplateFile(path, parser=self.parser,
                                        auto_reload=self.auto_reload,
                                        encoding='utf-8')
            except OSError:
                self.notexists[path] = True

        raise mako.exceptions.TopLevelLookupException(
            "Can not find template %s" % filename)
Esempio n. 9
0
        def load(self, filename):
            for path in self.search_path:
                path = os.path.join(path, filename)
                if (path in self.notexists) and (not self.auto_reload):
                    raise TemplateError("Can not find template %s" % filename)
                try:
                    return PageTemplateFile(path,
                                            parser=self.parser,
                                            auto_reload=self.auto_reload,
                                            debug=self.debug,
                                            encoding=self.encoding,
                                            translate=self.translate)
                except OSError:
                    self.notexists[path] = True

            raise TemplateError("Can not find template %s" % filename)
Esempio n. 10
0
 def render(self, *args, **kw):
     if args:
         slots, = args
         return self.render_macro("", slots=slots, parameters=kw)
     kw.update(self._bound_kwargs)
     return PageTemplateFile.render(self, **kw)
Esempio n. 11
0
 def __init__(self, relative_path, path):
     SkinObject.__init__(self, relative_path, path)
     PageTemplateFile.__init__(self, path)
Esempio n. 12
0
                isinstance(node.func, ast.Name):
            if node.func.id == KEY:
                arg = node.args[0]
                assert isinstance(arg, ast.Str)
                arg = arg.s
                print "{0}({1!r})".format(KEY, arg)
            elif node.func.id == KEY_PL:
                args = node.args[:2]
                for i in args:
                    assert isinstance(i, ast.Str)
                print "{0}({1!r}, {2!r})".format(KEY_PL, args[0].s, args[1].s)


class XgettextPythonExpr(PythonExpr):
    def parse(self, string):
        extract_msg(string)
        return super(self.__class__, self).parse(string)


PageTemplateFile.expression_types['python'] = XgettextPythonExpr

if __name__ == '__main__':
    try:
        while True:
            fname = raw_input()
            print '#', fname
            template = PageTemplateFile(fname)
            template.cook_check()
    except EOFError:
        pass
Esempio n. 13
0
 def setFromFilename(self, filename, _prefix=None):
     self._filename = filename
     self._prefix = _prefix
     self._template = PageTemplateFile(os.path.join(_prefix, filename))
     return
Esempio n. 14
0
 def render(self, **context):
     return PageTemplateFile.render(self, **context)
Esempio n. 15
0
 def __init__(self, relative_path, path):
     SkinObject.__init__(self, relative_path, path)
     PageTemplateFile.__init__(self, path)
Esempio n. 16
0
 def get_pt(self, text):
     f = open(self.TEMPFILENAME, "wb")
     f.write(text)
     f.close()
     pt = PageTemplateFile(self.TEMPFILENAME)
     return pt
Esempio n. 17
0
 def render(self, **context):
     return PageTemplateFile.render(self, **context)