Ejemplo n.º 1
0
        class Hash(ast.Node):
            _debug = True
            content = ast.seq(KVP, null=True)

            @property
            def _template(self):
                if len(self.content):
                    return "{\n%(content)s\n}"
                return "{}"
Ejemplo n.º 2
0
Archivo: ast.py Proyecto: stasm/l20n
class Entity(Entry):
    id = pyast.field(Identifier)
    index = pyast.seq(Expression, null=True)
    value = pyast.field(Value, null=True)
    attrs = pyast.dict(Attribute, null=True)
    local = pyast.field(bool, default=False)

    def _template(self):
        return "<%(id)s %(value)s>"
Ejemplo n.º 3
0
Archivo: ast.py Proyecto: stasm/l20n
class LOL(Node):
    body = pyast.seq(Entry, null=True)

    _template = '%(body)s'

    def _template_body(self):
        return [''] + ['\n'] * (len(self.body) - 1)

    _template_body_fillvalue = "\n"
Ejemplo n.º 4
0
Archivo: ast.py Proyecto: stasm/l20n
class ComplexString(String):
    content = pyast.seq((str, Expression))

    def _template_content(self):
        ws = []
        for n, elem in enumerate(self.content):
            if isinstance(self.content[n], String):
                self.content[n]._template = "%(content)s"
            if not isinstance(self.content[n], String):
                ws.append("{{")
            elif not isinstance(self.content[n - 1], String):
                ws.append("}}")
            else:
                ws.append("")
        return ws
Ejemplo n.º 5
0
class Example(pyast.Node):
    seq = pyast.seq(pyast.re("[a-z]{2}"))
Ejemplo n.º 6
0
Archivo: ast.py Proyecto: stasm/l20n
class Macro(Entry):
    id = pyast.field(Identifier)
    args = pyast.seq(VariableExpression)
    expression = pyast.field(Expression)
    attrs = pyast.seq(Attribute, null=True)
Ejemplo n.º 7
0
Archivo: ast.py Proyecto: stasm/l20n
class CallExpression(MemberExpression):
    callee = pyast.field(Expression)
    arguments = pyast.seq(Expression, null=True)
Ejemplo n.º 8
0
Archivo: ast.py Proyecto: stasm/l20n
class Hash(Value):
    content = pyast.seq(HashItem, null=True)
Ejemplo n.º 9
0
Archivo: ast.py Proyecto: stasm/l20n
class Array(Value):
    content = pyast.seq(Value, null=True)
Ejemplo n.º 10
0
 class Example(ast.Node):
     _debug = True
     field = ast.field(str, null=True)
     seq = ast.seq((str, int), null=True)
Ejemplo n.º 11
0
 class Example(ast.Node):
     _debug = True
     key = ast.field(Literal, null=True)
     value = ast.seq(Literal, null=True)
Ejemplo n.º 12
0
 class Example(ast.Node):
     _debug = True
     seq = ast.seq((ast.re("[a-z]{2}"), ast.re("[1-9]{1}")))
Ejemplo n.º 13
0
 class Example(ast.Node):
     _debug = True
     seq = ast.seq(ast.re("[a-z]{2}"))
Ejemplo n.º 14
0
 class Example(ast.Node):
     seq = ast.seq(str, null=False)
Ejemplo n.º 15
0
 class Example(ast.Node):
     _debug = True
     seq = ast.seq(str, null=True)