def atomic_write()

in gen.py [0:0]


def atomic_write(fname, content):
    # Write to an intermediate file, then do an atomic move into place.
    ### TODO: throw an alert if the new file is "too different" from the old
    tmp = '%s.%d' % (fname, os.getpid())
    open(tmp, 'w').write(content)
    os.rename(tmp, fname)