<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_fileset(self, fileset):
 """ Caches a single fileset (if the 'path' attribute is accessed and it has not been previously cached for example Parameters fileset : Fileset The fileset to cache prev_login : xnat.XNATSession An XNATSession object to use for the connection. A new one is created if one isn't provided Returns ------- primary_path : str The path of the primary file once it has been cached aux_paths : dict[str, str] A dictionary containing a mapping of auxiliary file names to paths """

        if fileset.format is None:
            raise ArcanaUsageError(
                "Attempting to download {}, which has not been assigned a "
                "file format (see Fileset.formatted)".format(fileset))
        self._check_repository(fileset)
        with self:  # Connect to the XNAT repository if haven't already
            xsession = self.get_xsession(fileset)
            xscan = xsession.scans[fileset.name]
            # Set URI so we can retrieve checksums if required
            fileset.uri = xscan.uri
            fileset.id = xscan.id
            cache_path = self._cache_path(fileset)
            need_to_download = True
            if op.exists(cache_path):
                if self._check_md5:
                    md5_path = cache_path + XnatRepo.MD5_SUFFIX
                    try:
                        with open(md5_path, 'r') as f:
                            cached_checksums = json.load(f)
                        if cached_checksums == fileset.checksums:
                            need_to_download = False
                    except IOError:
                        pass
                else:
                    need_to_download = False
            if need_to_download:
#                 if fileset._resource_name is not None:
                xresource = xscan.resources[fileset._resource_name]
#                 else:
#                     xresources = []
#                     for resource_name in fileset.format.xnat_resource_names:
#                         try:
#                             xresources.append(xscan.resources[resource_name])
#                         except KeyError:
#                             pass
#                     if not xresources:
#                         raise ArcanaError(
#                             "Could not find matching resource for {} ('{}') "
#                             "in {}, available resources are '{}'"
#                             .format(
#                                 self.format,
#                                 "', '".join(
#                                     fileset.format.xnat_resource_names),
#                                 xscan.uri,
#                                 "', '".join(
#                                     r.label
#                                     for r in list(xscan.resources.values()))))
#                     elif len(xresources) > 1:
#                         logger.warning(
#                             "Found multiple acceptable resources for {}: {}"
#                             .format(fileset,
#                                     ', '.join(str(r) for r in xresources)))
#                     xresource = xresources[0]
                # The path to the directory which the files will be
                # downloaded to.
                tmp_dir = cache_path + '.download'
                try:
                    # Attempt to make tmp download directory. This will
                    # fail if another process (or previous attempt) has
                    # already created it. In that case this process will
                    # wait to see if that download finishes successfully,
                    # and if so use the cached version.
                    os.mkdir(tmp_dir)
                except OSError as e:
                    if e.errno == errno.EEXIST:
                        # Another process may be concurrently downloading
                        # the same file to the cache. Wait for
                        # 'race_cond_delay' seconds and then check that it
                        # has been completed or assume interrupted and
                        # redownload.
                        self._delayed_download(
                            tmp_dir, xresource, xscan, fileset,
                            xsession.label, cache_path,
                            delay=self._race_cond_delay)
                    else:
                        raise
                else:
                    self.download_fileset(
                        tmp_dir, xresource, xscan, fileset,
                        xsession.label, cache_path)
                    shutil.rmtree(tmp_dir)
        if not fileset.format.directory:
            (primary_path, aux_paths) = fileset.format.assort_files(
                op.join(cache_path, f) for f in os.listdir(cache_path))
        else:
            primary_path = cache_path
            aux_paths = None
        return primary_path, aux_paths