Exemplo n.º 1
0
 def to_section(self, tag, children):
     name, attrs = tag
     attrs = attrs if len(attrs) > 1 else [self.typed(a) for a in attrs]
     return Section(name=name.value,
                    attrs=attrs,
                    children=children,
                    lineno=name.lineno,
                    src=self.ctx)
Exemplo n.º 2
0
 def to_entries(self, x):
     ret = []
     for i in x:
         name, attrs, body = i
         if body:
             for n in [name.value] + attrs:
                 ret.append(Section(name=n, children=body, lineno=name.lineno))
         else:
             ret.append(Directive(name=name.value, attrs=attrs, lineno=name.lineno))
     return ret
Exemplo n.º 3
0
 def to_entry(name, rest):
     if isinstance(rest, list):
         return Section(name=name.value,
                        children=rest,
                        lineno=name.lineno,
                        src=ctx)
     return Directive(name=name.value,
                      attrs=[rest],
                      lineno=name.lineno,
                      src=ctx)
Exemplo n.º 4
0
 def to_entry(name, attrs, body):
     if body == ";":
         return Directive(name=name.value,
                          attrs=attrs,
                          lineno=name.lineno,
                          src=self)
     return Section(name=name.value,
                    attrs=attrs,
                    children=body,
                    lineno=name.lineno,
                    src=self)
Exemplo n.º 5
0
def to_entries(x):
    ret = []
    for i in x:
        name, attrs, body = i
        if body:
            for n in [name.value] + attrs:
                ret.append(Section(name=n, children=body, lineno=name.lineno))
        else:
            attrs = [attrs] if not isinstance(attrs, list) else attrs
            ret.append(
                Directive(name=name.value, attrs=attrs, lineno=name.lineno))
    return ret
Exemplo n.º 6
0
 def to_section(name, rest):
     return Section(name=name.value.strip(), children=rest, lineno=name.lineno, src=ctx)
Exemplo n.º 7
0
 def to_section(name, attrs, body):
     return Section(name=name.value,
                    attrs=attrs,
                    children=body,
                    lineno=name.lineno,
                    src=self)