示例#1
0
文件: show.py 项目: rjc/dbts
def print_version_graph(graph, *, ilevel=0):
    vcolors = dict(
        salmon='{t.red}',
        chartreuse='{t.green}',
    )

    def render(node):
        label = str(node)
        if label == 'some versions':
            label = '...'
        color = vcolors.get(node.get('fillcolor'))
        fmt1 = fmt2 = '{line}'
        if color is not None:
            fmt1 = color + fmt1 + '{t.off}'
        label = '\n'.join(
            colorterm.format(fmt1 if i == 0 else fmt2, line=line)
            for i, line in enumerate(label.splitlines()))
        return label

    bullet = '∙'
    try:
        bullet.encode(sys.stdout.encoding)
    except UnicodeError:
        bullet = '*'
    s = graph.pformat(render=render, bullet=bullet)
    s = s.rstrip('\n')
    s = indent.indent(s, ilevel)
    print(s)
示例#2
0
文件: show.py 项目: jwilk/dbts
def print_version_graph(graph, *, ilevel=0):
    vcolors = dict(
        salmon='{t.red}',
        chartreuse='{t.green}',
    )
    def render(node):
        label = str(node)
        if label == 'some versions':
            label = '...'
        color = vcolors.get(node.get('fillcolor'))
        fmt1 = fmt2 = '{line}'
        if color is not None:
            fmt1 = color + fmt1 + '{t.off}'
        label = '\n'.join(
            colorterm.format(fmt1 if i == 0 else fmt2, line=line)
            for i, line in enumerate(label.splitlines())
        )
        return label
    bullet = '∙'
    try:
        bullet.encode(sys.stdout.encoding)
    except UnicodeError:
        bullet = '*'
    s = graph.pformat(render=render, bullet=bullet)
    s = s.rstrip('\n')
    s = indent.indent(s, ilevel)
    print(s)
示例#3
0
文件: dotparser.py 项目: jwilk/dbts
 def p(node_name, ilevel):
     if node_name in seen:
         return
     node = self.nodes[node_name]
     label = render(node)
     label = indent.indent(
         label,
         max(0, (ilevel - 1) * 2),
         bullet=(bullet + ' ' if ilevel > 0 else '')
     )
     print(label, file=file)
     seen.add(node_name)
     for child in sorted(self.edges[node_name]):
         p(child, ilevel + 1)