/usr/share/pyshared/classytags/blocks.py is in python-django-classy-tags 0.3.4.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 33 34 35 36 37 38 39 40 41 42 43 44 45 | # -*- coding: utf-8 -*-
from django.core.exceptions import ImproperlyConfigured
def _collect(name, parser):
collector = getattr(name, 'collect', None)
if callable(collector):
return collector(parser)
return name
class BlockDefinition(object):
"""
Definition of 'parse-until-blocks' used by the parser.
"""
def __init__(self, alias, *names):
self.alias = alias
self.names = names
def validate(self, options):
for name in self.names:
validator = getattr(name, 'validate', None)
if callable(validator):
validator(options)
def collect(self, parser):
return [_collect(name, parser) for name in self.names]
class VariableBlockName(object):
def __init__(self, template, argname):
self.template = template
self.argname = argname
def validate(self, options):
if self.argname not in options.all_argument_names:
raise ImproperlyConfigured(
"Invalid block definition, %r not a valid argument name, "
"available argument names: %r" % (self.argname,
options.all_argument_names)
)
def collect(self, parser):
value = parser.kwargs[self.argname]
return self.template % {'value': value.literal}
|