Example #1
0
 def to_directive(x):
     name, rest = x
     rest = [rest] if rest is not None else []
     return Directive(name=name.value.strip(),
                      attrs=rest,
                      lineno=name.lineno,
                      src=ctx)
Example #2
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)
 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
Example #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)
Example #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
Example #6
0
 def to_directive(self, name, attrs):
     attrs = attrs if len(attrs) > 1 else [self.typed(a) for a in attrs]
     return Directive(name=name.value,
                      attrs=attrs,
                      lineno=name.lineno,
                      src=self.ctx)
Example #7
0
 def to_entry(name, rest):
     rest = [] if not rest else [rest]
     return Directive(name=name.value, attrs=rest, lineno=name.lineno, src=ctx)
Example #8
0
 def to_directive_noval(name, sep):
     return Directive(name=name.value,
                      attrs=[],
                      lineno=name.lineno,
                      src=self)
Example #9
0
 def to_directive(name, attrs):
     return Directive(name=name.value,
                      attrs=attrs,
                      lineno=name.lineno,
                      src=self)