insights/parsr/query/__init__.py
def pretty_format(root, indent=4):
    """
    pretty_format generates a text representation of a model as a list of
    lines.
    """
    results = []

    def sep():
        if results and results[-1] != "":
            results.append("")

    def inner(d, prefix=""):
        if isinstance(d, Result):
            for c in d.children:
                inner(c, prefix)
            return
        if d.children:
            sep()
            name = d.name or ""
            header = name if not d.attrs else " ".join([name, d.string_value])
            if header:
                results.append(prefix + "[" + header + "]")
            prep = prefix + (" " * indent)
            for c in d.children:
                inner(c, prep)
            sep()
        else:
            results.append(prefix + (d.name or "") + ": " + d.string_value)

    inner(root)
    return results

    pretty_format generates a text representation of a model as a list of
    lines.
    
pretty_format generates a text representation of a model as a list of
lines.
pretty_format generates a text representation of a model as a list of lines .
def pretty_format(root, indent=4):
    results = []
    def sep():
        if results and results[-1] != "":
            results.append("")
    def inner(d, prefix=""):
        if isinstance(d, Result):
            for c in d.children:
                inner(c, prefix)
            return
        if d.children:
            sep()
            name = d.name or ""
            header = name if not d.attrs else " ".join([name, d.string_value])
            if header:
                results.append(prefix + "[" + header + "]")
            prep = prefix + (" " * indent)
            for c in d.children:
                inner(c, prep)
            sep()
        else:
            results.append(prefix + (d.name or "") + ": " + d.string_value)
    inner(root)
    return results
def pretty_format ( root , indent = 4 ) : results = [ ] def sep ( ) : if results and results [ - 1 ] != "" : results . append ( "" ) def inner ( d , prefix = "" ) : if isinstance ( d , Result ) : for c in d . children : inner ( c , prefix ) return if d . children : sep ( ) name = d . name or "" header = name if not d . attrs else " " . join ( [ name , d . string_value ] ) if header : results . append ( prefix + "[" + header + "]" ) prep = prefix + ( " " * indent ) for c in d . children : inner ( c , prep ) sep ( ) else : results . append ( prefix + ( d . name or "" ) + ": " + d . string_value ) inner ( root ) return results
pretty_format generates a text representation of a model as a list of
lines.
pretty_format generates a text representation of a model as a list of lines .
"""
    pretty_format generates a text representation of a model as a list of
    lines.
    """
root
indent