def patch_sourcefile(fname, in_text, out_text, silent_mode=False):
    """Replace a string in a source file"""
    import io
    if osp.isfile(fname) and not in_text == out_text:
        with io.open(fname, 'r') as fh:
            content = fh.read()
        new_content = content.replace(in_text, out_text)
        if not new_content == content:
            if not silent_mode:
                print("patching ", fname, "from", in_text, "to", out_text)
            with io.open(fname, 'wt') as fh:
                fh.write(new_content)

# =============================================================================
# Patch sourcelines (instead of forking packages)
# =============================================================================
dataset/ETHPy150Open winpython/winpython/winpython/utils.py/patch_sourcefile/original