def clean_built(self, storage):
        """
        Clear any static files that aren't from the apps.

        """
        build_dirs, built_files = self.find_all(storage)

        found_files = set()
        for finder in finders.get_finders():
            for path, s in finder.list([]):
                # Prefix the relative path if the source storage contains it
                if getattr(s, 'prefix', None):
                    prefixed_path = os.path.join(s.prefix, path)
                else:
                    prefixed_path = path

                found_files.add(prefixed_path)

        stale_files = built_files - found_files

        for fpath in stale_files:
            self.log(u"Deleting '%s'" % smart_unicode(fpath), level=1)
            storage.delete(fpath)

        found_dirs = set()
        for f in found_files:
            path = f
            while True:
                path = os.path.dirname(path)
                found_dirs.add(path)
                if not path:
                    break

        stale_dirs = set(build_dirs) - found_dirs

        for fpath in stale_dirs:
            try:
                storage.delete(fpath)
            except __HOLE__:
                self.log(u"Couldn't remove empty directory '%s'" % smart_unicode(fpath), level=1)
            else:
                self.log(u"Deleted empty directory '%s'" % smart_unicode(fpath), level=1)
dataset/ETHPy150Open hzdg/django-staticbuilder/staticbuilder/management/commands/collectforbuild.py/Command.clean_built