<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def matches(self, fileset):
 """ Checks to see whether the format matches the given fileset Parameters fileset : Fileset The fileset to check """

        if fileset._resource_name is not None:
            return (fileset._resource_name in self.resource_names(
                fileset.repository.type))
        elif self.directory:
            if op.isdir(fileset.path):
                if self.within_dir_exts is None:
                    return True
                else:
                    # Get set of all extensions in the directory
                    return self.within_dir_exts == frozenset(
                        split_extension(f)[1] for f in os.listdir(fileset.path)
                        if not f.startswith('.'))
            else:
                return False
        else:
            if op.isfile(fileset.path):
                all_paths = [fileset.path] + fileset._potential_aux_files
                try:
                    primary_path = self.assort_files(all_paths)[0]
                except ArcanaFileFormatError:
                    return False
                else:
                    return primary_path == fileset.path
            else:
                return False