def _stamp_version(filename):
    found, out = False, list()
    try:
        f = open(filename, 'r')
    except (__HOLE__, OSError):
        print("Couldn't find file %s to stamp version" % filename, file=sys.stderr)
        return
    # END handle error, usually happens during binary builds
    for line in f:
        if '__version__ =' in line:
            line = line.replace("'git'", "'%s'" % VERSION)
            found = True
        out.append(line)
    f.close()

    if found:
        f = open(filename, 'w')
        f.writelines(out)
        f.close()
    else:
        print("WARNING: Couldn't find version line in file %s" % filename, file=sys.stderr)
dataset/ETHPy150Open gitpython-developers/GitPython/setup.py/_stamp_version