コード例 #1
0
ファイル: parsetree.py プロジェクト: srhrshr/docassemble
    def __init__(self, keyword, attributes, **kwargs):
        expressions = ['buffered', 'cached', 'args'] + [
            c for c in attributes if c.startswith('cache_')]

        super(BlockTag, self).__init__(
            keyword,
            attributes,
            expressions,
            ('name', 'filter', 'decorator'),
            (),
            **kwargs)
        name = attributes.get('name')
        if name and not re.match(r'^[\w_]+$', name):
            raise exceptions.CompileException(
                "%block may not specify an argument signature",
                **self.exception_kwargs)
        if not name and attributes.get('args', None):
            raise exceptions.CompileException(
                "Only named %blocks may specify args",
                **self.exception_kwargs
            )
        self.body_decl = ast.FunctionArgs(attributes.get('args', ''),
                                          **self.exception_kwargs)

        self.name = name
        self.decorator = attributes.get('decorator', '')
        self.filter_args = ast.ArgumentList(
            attributes.get('filter', ''),
            **self.exception_kwargs)
コード例 #2
0
ファイル: parsetree.py プロジェクト: srhrshr/docassemble
 def __init__(self, keyword, attributes, **kwargs):
     super(TextTag, self).__init__(
         keyword,
         attributes, (),
         ('filter'), (), **kwargs)
     self.filter_args = ast.ArgumentList(
         attributes.get('filter', ''),
         **self.exception_kwargs)
コード例 #3
0
    def __init__(self, keyword, attributes, **kwargs):
        expressions = \
            ['cached', 'args', 'expression_filter', 'enable_loop'] + \
            [c for c in attributes if c.startswith('cache_')]

        super(PageTag, self).__init__(keyword, attributes, expressions, (), (),
                                      **kwargs)
        self.body_decl = ast.FunctionArgs(attributes.get('args', ''),
                                          **self.exception_kwargs)
        self.filter_args = ast.ArgumentList(
            attributes.get('expression_filter', ''), **self.exception_kwargs)
コード例 #4
0
    def __init__(self, keyword, attributes, **kwargs):
        expressions = ['buffered', 'cached'
                       ] + [c for c in attributes if c.startswith('cache_')]

        super(DefTag, self).__init__(keyword, attributes, expressions,
                                     ('name', 'filter', 'decorator'),
                                     ('name', ), **kwargs)
        name = attributes['name']
        if re.match(r'^[\w_]+$', name):
            raise exceptions.CompileException("Missing parenthesis in %def",
                                              **self.exception_kwargs)
        self.function_decl = ast.FunctionDecl("def " + name + ":pass",
                                              **self.exception_kwargs)
        self.name = self.function_decl.funcname
        self.decorator = attributes.get('decorator', '')
        self.filter_args = ast.ArgumentList(attributes.get('filter', ''),
                                            **self.exception_kwargs)
コード例 #5
0
 def __init__(self, text, escapes, **kwargs):
     super(Expression, self).__init__(**kwargs)
     self.text = text
     self.escapes = escapes
     self.escapes_code = ast.ArgumentList(escapes, **self.exception_kwargs)
     self.code = ast.PythonCode(text, **self.exception_kwargs)