def report(self, stream):
        heading(stream, 'Used Templates (%s)' % len(self.used_templates))
        bulleted(stream, sorted(self.used_templates))

        from django.conf import settings
        from django.template.loader import template_source_loaders
        from django.template.loaders.filesystem import Loader as FileSystemLoader
        from django.template.loaders.app_directories import Loader as AppDirectoryLoader

        def filter_ignored(paths):
            for path in paths:
                for prefix in self.ignore_prefixes:
                    if os.path.commonprefix((prefix, path)) == prefix:
                        break
                else:
                    yield path

        available_templates = set()
        for loader in template_source_loaders:
            # XXX: This should only execute once per class since you can't
            # actually instantiate the loaders multiple times.
            if isinstance(loader, FileSystemLoader):
                for directory in settings.TEMPLATE_DIRS:
                    available_templates.update(filter_ignored(files(directory)))

            elif isinstance(loader, AppDirectoryLoader):
                from django.template.loaders.app_directories import app_template_dirs
                for directory in app_template_dirs:
                    available_templates.update(filter_ignored(files(directory)))

        self.unused_templates = available_templates - self.used_templates
        heading(stream, 'Unused Templates (%s)' % len(self.unused_templates))
        bulleted(stream, sorted(self.unused_templates))

        if self.outfile:
            with open(self.outfile, 'w') as out:
                json.dump({
                    'used': list(self.used_templates),
                    'unused': list(self.unused_templates),
                }, out)
dataset/ETHPy150Open disqus/nose-template-usage/templateusage/plugin.py/TemplateUsageReportPlugin.report/original