<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def prune_directory(self):
 """Delete any objects that can be loaded and are expired according to the current lifetime setting. A file will be deleted if the following conditions are met: - The file extension matches :py:meth:`bucketcache.backends.Backend.file_extension` - The object can be loaded by the configured backend. - The object's expiration date has passed. Returns: File size and number of files deleted. :rtype: :py:class:`~bucketcache.utilities.PrunedFilesInfo` .. note:: For any buckets that share directories, ``prune_directory`` will affect files saved with both, if they use the same backend class. This is not destructive, because only files that have expired according to the lifetime of the original bucket are deleted. """

        glob = '*.{ext}'.format(ext=self.backend.file_extension)
        totalsize = 0
        totalnum = 0
        for f in self._path.glob(glob):
            filesize = f.stat().st_size
            key_hash = f.stem
            in_cache = key_hash in self._cache
            try:
                self._get_obj_from_hash(key_hash)
            except KeyExpirationError:
                # File has been deleted by `_get_obj_from_hash`
                totalsize += filesize
                totalnum += 1
            except KeyInvalidError:
                pass
            except Exception:
                raise
            else:
                if not in_cache:
                    del self._cache[key_hash]
        return PrunedFilesInfo(size=totalsize, num=totalnum)