def find_file(self, path, tgt_env='base', **kwargs):  # pylint: disable=W0613
        fnd = {'path': '',
               'rel': ''}
        if os.path.isabs(path) or tgt_env not in self.envs():
            return fnd

        dest = os.path.join(self.cache_root, 'refs', tgt_env, path)
        hashes_glob = os.path.join(self.hash_cachedir,
                                   tgt_env,
                                   '{0}.hash.*'.format(path))
        blobshadest = os.path.join(self.hash_cachedir,
                                   tgt_env,
                                   '{0}.hash.blob_sha1'.format(path))
        lk_fn = os.path.join(self.hash_cachedir,
                             tgt_env,
                             '{0}.lk'.format(path))
        destdir = os.path.dirname(dest)
        hashdir = os.path.dirname(blobshadest)
        if not os.path.isdir(destdir):
            try:
                os.makedirs(destdir)
            except OSError:
                # Path exists and is a file, remove it and retry
                os.remove(destdir)
                os.makedirs(destdir)
        if not os.path.isdir(hashdir):
            try:
                os.makedirs(hashdir)
            except OSError:
                # Path exists and is a file, remove it and retry
                os.remove(hashdir)
                os.makedirs(hashdir)

        for repo in self.remotes:
            if repo.mountpoint \
                    and not path.startswith(repo.mountpoint + os.path.sep):
                continue
            repo_path = path[len(repo.mountpoint):].lstrip(os.path.sep)
            if repo.root:
                repo_path = os.path.join(repo.root, repo_path)

            blob, blob_hexsha = repo.find_file(repo_path, tgt_env)
            if blob is None:
                continue

            salt.fileserver.wait_lock(lk_fn, dest)
            if os.path.isfile(blobshadest) and os.path.isfile(dest):
                with salt.utils.fopen(blobshadest, 'r') as fp_:
                    sha = fp_.read()
                    if sha == blob_hexsha:
                        fnd['rel'] = path
                        fnd['path'] = dest
                        return fnd
            with salt.utils.fopen(lk_fn, 'w+') as fp_:
                fp_.write('')
            for filename in glob.glob(hashes_glob):
                try:
                    os.remove(filename)
                except Exception:
                    pass
            # Write contents of file to their destination in the FS cache
            repo.write_file(blob, dest)
            with salt.utils.fopen(blobshadest, 'w+') as fp_:
                fp_.write(blob_hexsha)
            try:
                os.remove(lk_fn)
            except OSError:
                pass
            fnd['rel'] = path
            fnd['path'] = dest
            return fnd

        # No matching file was found in tgt_env. Return a dict with empty paths
        # so the calling function knows the file could not be found.
        return fnd
Collapse self.body to a single string; replace it and return it.
dataset/ETHPy150Open saltstack/salt/salt/utils/gitfs.py/GitFS.find_file--crossover with--dataset/ETHPy150Open clips/pattern/pattern/server/cherrypy/cherrypy/_cprequest.py/Response.collapse_body