def path_exists(path, basedir=None):
    """Case sensitive, for windows, optional
    basedir for skip caps check for tmp folders in testing for example (returned always
    in lowercase for some strange reason)"""
    exists = os.path.exists(path)
    if not exists or sys.platform == "linux2":
        return exists

    path = os.path.normpath(path)

    if basedir:
        path = os.path.relpath(path, basedir)
        chunks = path.split(os.sep)
        tmp = basedir
    else:
        chunks = path.split(os.sep)
        tmp = chunks[0]  # Skip unit (c:)
        chunks = chunks[1:]

    for chunk in chunks[0:]:
        tmp = tmp + os.sep
        if chunk and chunk not in os.listdir(tmp):
            return False
        tmp += chunk
    return True
dataset/ETHPy150Open conan-io/conan/conans/util/files.py/path_exists/original