

def clean_content(self):
    content = self.cleaned_data.get('content', '')
    if content:
        origin = StringOrigin(content)
        try:
            from django.template.debug import DebugLexer, DebugParser
        except ImportError:
            from django.template import Template
            try:
                template = Template(template_string=origin)
            except Exception as e:
                self.exc_info = {
                    'message': e.args,
                    'line': e.token.lineno,
                    'name': origin.name,
                }
                raise forms.ValidationError('Invalid Django Template')
            try:
                template.compile_nodelist()
            except Exception as e:
                e.template_debug = template.get_exception_info(e, e.token)
                self.exc_info = e.template_debug
                raise forms.ValidationError('Parsing Error')
        else:
            lexer = DebugLexer(content, origin)
            try:
                parser = DebugParser(origin.tokenize())
                parser.parse()
            except Exception as e:
                self.exc_info = sys.exc_info()
                if (not hasattr(self.exc_info[1], 'django_template_source')):
                    self.exc_info[1].django_template_source = (origin, (0, 0))
                raise forms.ValidationError('Invalid Django Template')
    return content

dataset/ETHPy150Open caktus/django-scribbler/scribbler/forms.py ScribbleFormMixin.clean_content/VarMisuse@196/243 `lexer`->`origin`