File: utils.py

package info (click to toggle)
python-django-tagging 1%3A0.4.5-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 372 kB
  • ctags: 386
  • sloc: python: 2,246; makefile: 168
file content (32 lines) | stat: -rw-r--r-- 805 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"""
Tests utils for tagging.
"""
from django.template.loaders.base import Loader
try:
    from django.template import Origin
except ImportError:
    class Origin(object):
        def __init__(self, **kwargs):
            for k, v in kwargs.items():
                setattr(self, k, v)


class VoidLoader(Loader):
    """
    Template loader which is always returning
    an empty template.
    """
    is_usable = True
    _accepts_engine_in_init = True

    def get_template_sources(self, template_name):
        yield Origin(
            name='voidloader',
            template_name=template_name,
            loader=self)

    def get_contents(self, origin):
        return ''

    def load_template_source(self, template_name, template_dirs=None):
        return ('', 'voidloader:%s' % template_name)