io.py
author Dmitriy Morozov <dmitriy@mrzv.org>
Wed, 27 Jul 2011 13:41:40 -0700
changeset 20 0b7b52941b22
parent 15 30a851aa0675
permissions -rw-r--r--
When drawing edges as pipes use the selected color

def line_blocks(filename, size = 1):
    block = []
    with open(filename) as f:
        for line in f:
            if not line.strip() or line.startswith('#'): continue
            block.append(line)
            if len(block) == size:
                yield block
                block = []