コード例 #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 "{}"
コード例 #2
0
ファイル: ast.py プロジェクト: 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>"
コード例 #3
0
ファイル: ast.py プロジェクト: 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"
コード例 #4
0
ファイル: ast.py プロジェクト: 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
コード例 #5
0
ファイル: update-locale.py プロジェクト: spagy/python-l20n
class Example(pyast.Node):
    seq = pyast.seq(pyast.re("[a-z]{2}"))
コード例 #6
0
ファイル: ast.py プロジェクト: stasm/l20n
class Macro(Entry):
    id = pyast.field(Identifier)
    args = pyast.seq(VariableExpression)
    expression = pyast.field(Expression)
    attrs = pyast.seq(Attribute, null=True)
コード例 #7
0
ファイル: ast.py プロジェクト: stasm/l20n
class CallExpression(MemberExpression):
    callee = pyast.field(Expression)
    arguments = pyast.seq(Expression, null=True)
コード例 #8
0
ファイル: ast.py プロジェクト: stasm/l20n
class Hash(Value):
    content = pyast.seq(HashItem, null=True)
コード例 #9
0
ファイル: ast.py プロジェクト: stasm/l20n
class Array(Value):
    content = pyast.seq(Value, null=True)
コード例 #10
0
ファイル: base.py プロジェクト: riccitensor/pyast
 class Example(ast.Node):
     _debug = True
     field = ast.field(str, null=True)
     seq = ast.seq((str, int), null=True)
コード例 #11
0
ファイル: base.py プロジェクト: riccitensor/pyast
 class Example(ast.Node):
     _debug = True
     key = ast.field(Literal, null=True)
     value = ast.seq(Literal, null=True)
コード例 #12
0
ファイル: base.py プロジェクト: riccitensor/pyast
 class Example(ast.Node):
     _debug = True
     seq = ast.seq((ast.re("[a-z]{2}"), ast.re("[1-9]{1}")))
コード例 #13
0
ファイル: base.py プロジェクト: riccitensor/pyast
 class Example(ast.Node):
     _debug = True
     seq = ast.seq(ast.re("[a-z]{2}"))
コード例 #14
0
ファイル: base.py プロジェクト: riccitensor/pyast
 class Example(ast.Node):
     seq = ast.seq(str, null=False)
コード例 #15
0
ファイル: base.py プロジェクト: riccitensor/pyast
 class Example(ast.Node):
     _debug = True
     seq = ast.seq(str, null=True)