def fileset(self, name, from_study=None, format=None):  # @ReservedAssignment @IgnorePep8
        """
        Gets the fileset named 'name' produced by the Study named 'study' if
        provided. If a spec is passed instead of a str to the name argument,
        then the study will be set from the spec iff it is derived

        Parameters
        ----------
        name : str | FilesetSpec
            The name of the fileset or a spec matching the given name
        from_study : str | None
            Name of the study that produced the fileset if derived. If None
            and a spec is passed instaed of string to the name argument then
            the study name will be taken from the spec instead.
        format : FileFormat | str | None
            Either the format of the fileset to return or the name of the
            format. If None and only a single fileset is found for the given
            name and study then that is returned otherwise an exception is
            raised
        """
        if isinstance(name, BaseFileset):
            if from_study is None and name.derived:
                from_study = name.study.name
            name = name.name
        try:
            format_dct = self._filesets[(name, from_study)]
        except KeyError:
            available = [
                ('{}(format={})'.format(f.name, f._resource_name)
                 if f._resource_name is not None else f.name)
                for f in self.filesets if f.from_study == from_study]
            other_studies = [
                (f.from_study if f.from_study is not None else '<root>')
                for f in self.filesets if f.name == name]
            if other_studies:
                msg = (". NB: matching fileset(s) found for '{}' study(ies) "
                       "('{}')".format(name, "', '".join(other_studies)))
            else:
                msg = ''
            raise ArcanaNameError(
                name,
                ("{} doesn't have a fileset named '{}'{} "
                   "(available '{}'){}"
                   .format(self, name,
                           (" from study '{}'".format(from_study)
                            if from_study is not None else ''),
                           "', '".join(available), msg)))
        else:
            if format is None:
                all_formats = list(format_dct.values())
                if len(all_formats) > 1:
                    raise ArcanaNameError(
                        "Multiple filesets found for '{}'{} in {} with formats"
                        " {}. Need to specify a format"
                        .format(name, ("in '{}'".format(from_study)
                                       if from_study is not None else ''),
                                self, "', '".join(format_dct.keys())))
                fileset = all_formats[0]
            else:
                try:
                    if isinstance(format, str):
                        fileset = format_dct[format]
                    else:
                        try:
                            fileset = format_dct[format.ext]
                        except KeyError:
                            fileset = None
                            for rname, rfileset in format_dct.items():
                                if rname in format.resource_names(
                                        self.tree.repository.type):
                                    fileset = rfileset
                                    break
                            if fileset is None:
                                raise
                except KeyError:
                    raise ArcanaNameError(
                        format,
                        ("{} doesn't have a fileset named '{}'{} with "
                         "format '{}' (available '{}'){}"
                           .format(self, name,
                                   (" from study '{}'".format(from_study)
                                    if from_study is not None else ''),
                                   format,
                                   "', '".join(format_dct.keys()), msg)))

        return fileset
Gets the fileset named 'name' produced by the Study named 'study' if
        provided. If a spec is passed instead of a str to the name argument,
        then the study will be set from the spec iff it is derived

        Parameters
        ----------
        name : str | FilesetSpec
            The name of the fileset or a spec matching the given name
        from_study : str | None
            Name of the study that produced the fileset if derived. If None
            and a spec is passed instaed of string to the name argument then
            the study name will be taken from the spec instead.
        format : FileFormat | str | None
            Either the format of the fileset to return or the name of the
            format. If None and only a single fileset is found for the given
            name and study then that is returned otherwise an exception is
            raised