def read_text_file(filename):
    with open(filename, 'rb') as fp:
        data = fp.read()

    encodings = ['utf-8', locale.getpreferredencoding(False), 'latin1']
    for enc in encodings:
        try:
            data = data.decode(enc)
        except UnicodeDecodeError:
            continue
        break

    assert type(data) != bytes  # Latin1 should have worked.
    return data
Return the contents of *filename*.
dataset/ETHPy150Open anzev/hedwig/build/pip/pip/utils/__init__.py/read_text_file