Source

canvas2dot / canvas2dot.py

Full commit
from itertools import tee, izip

__version__ = '0.1.0'


# http://docs.python.org/2/library/itertools.html#recipes
def pairwise(iterable):
    's -> (s0,s1), (s1,s2), (s2, s3), ...'
    a, b = tee(iterable)
    next(b, None)
    return izip(a, b)


def chain2dot(chn, fo):
    for head, tail in pairwise(reversed(chn.tasks)):
        fo.write('{} -> {}'.format(head.task, tail.task))


def chord2dot(chrd, fo):
    tail = chrd.body.task
    fo.write('subgraph {