Mercurial > repos > shellac > guppy_basecaller
annotate env/lib/python3.7/site-packages/jinja2/exceptions.py @ 0:26e78fe6e8c4 draft
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
| author | shellac | 
|---|---|
| date | Sat, 02 May 2020 07:14:21 -0400 | 
| parents | |
| children | 
| rev | line source | 
|---|---|
| 
0
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
1 # -*- coding: utf-8 -*- | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
2 from ._compat import imap | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
3 from ._compat import implements_to_string | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
4 from ._compat import PY2 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
5 from ._compat import text_type | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
6 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
7 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
8 class TemplateError(Exception): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
9 """Baseclass for all template errors.""" | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
10 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
11 if PY2: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
12 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
13 def __init__(self, message=None): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
14 if message is not None: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
15 message = text_type(message).encode("utf-8") | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
16 Exception.__init__(self, message) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
17 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
18 @property | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
19 def message(self): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
20 if self.args: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
21 message = self.args[0] | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
22 if message is not None: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
23 return message.decode("utf-8", "replace") | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
24 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
25 def __unicode__(self): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
26 return self.message or u"" | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
27 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
28 else: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
29 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
30 def __init__(self, message=None): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
31 Exception.__init__(self, message) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
32 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
33 @property | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
34 def message(self): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
35 if self.args: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
36 message = self.args[0] | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
37 if message is not None: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
38 return message | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
39 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
40 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
41 @implements_to_string | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
42 class TemplateNotFound(IOError, LookupError, TemplateError): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
43 """Raised if a template does not exist. | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
44 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
45 .. versionchanged:: 2.11 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
46 If the given name is :class:`Undefined` and no message was | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
47 provided, an :exc:`UndefinedError` is raised. | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
48 """ | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
49 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
50 # looks weird, but removes the warning descriptor that just | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
51 # bogusly warns us about message being deprecated | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
52 message = None | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
53 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
54 def __init__(self, name, message=None): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
55 IOError.__init__(self, name) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
56 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
57 if message is None: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
58 from .runtime import Undefined | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
59 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
60 if isinstance(name, Undefined): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
61 name._fail_with_undefined_error() | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
62 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
63 message = name | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
64 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
65 self.message = message | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
66 self.name = name | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
67 self.templates = [name] | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
68 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
69 def __str__(self): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
70 return self.message | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
71 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
72 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
73 class TemplatesNotFound(TemplateNotFound): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
74 """Like :class:`TemplateNotFound` but raised if multiple templates | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
75 are selected. This is a subclass of :class:`TemplateNotFound` | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
76 exception, so just catching the base exception will catch both. | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
77 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
78 .. versionchanged:: 2.11 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
79 If a name in the list of names is :class:`Undefined`, a message | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
80 about it being undefined is shown rather than the empty string. | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
81 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
82 .. versionadded:: 2.2 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
83 """ | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
84 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
85 def __init__(self, names=(), message=None): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
86 if message is None: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
87 from .runtime import Undefined | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
88 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
89 parts = [] | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
90 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
91 for name in names: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
92 if isinstance(name, Undefined): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
93 parts.append(name._undefined_message) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
94 else: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
95 parts.append(name) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
96 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
97 message = u"none of the templates given were found: " + u", ".join( | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
98 imap(text_type, parts) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
99 ) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
100 TemplateNotFound.__init__(self, names and names[-1] or None, message) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
101 self.templates = list(names) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
102 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
103 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
104 @implements_to_string | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
105 class TemplateSyntaxError(TemplateError): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
106 """Raised to tell the user that there is a problem with the template.""" | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
107 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
108 def __init__(self, message, lineno, name=None, filename=None): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
109 TemplateError.__init__(self, message) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
110 self.lineno = lineno | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
111 self.name = name | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
112 self.filename = filename | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
113 self.source = None | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
114 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
115 # this is set to True if the debug.translate_syntax_error | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
116 # function translated the syntax error into a new traceback | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
117 self.translated = False | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
118 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
119 def __str__(self): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
120 # for translated errors we only return the message | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
121 if self.translated: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
122 return self.message | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
123 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
124 # otherwise attach some stuff | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
125 location = "line %d" % self.lineno | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
126 name = self.filename or self.name | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
127 if name: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
128 location = 'File "%s", %s' % (name, location) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
129 lines = [self.message, " " + location] | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
130 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
131 # if the source is set, add the line to the output | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
132 if self.source is not None: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
133 try: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
134 line = self.source.splitlines()[self.lineno - 1] | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
135 except IndexError: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
136 line = None | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
137 if line: | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
138 lines.append(" " + line.strip()) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
139 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
140 return u"\n".join(lines) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
141 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
142 def __reduce__(self): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
143 # https://bugs.python.org/issue1692335 Exceptions that take | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
144 # multiple required arguments have problems with pickling. | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
145 # Without this, raises TypeError: __init__() missing 1 required | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
146 # positional argument: 'lineno' | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
147 return self.__class__, (self.message, self.lineno, self.name, self.filename) | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
148 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
149 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
150 class TemplateAssertionError(TemplateSyntaxError): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
151 """Like a template syntax error, but covers cases where something in the | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
152 template caused an error at compile time that wasn't necessarily caused | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
153 by a syntax error. However it's a direct subclass of | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
154 :exc:`TemplateSyntaxError` and has the same attributes. | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
155 """ | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
156 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
157 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
158 class TemplateRuntimeError(TemplateError): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
159 """A generic runtime error in the template engine. Under some situations | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
160 Jinja may raise this exception. | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
161 """ | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
162 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
163 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
164 class UndefinedError(TemplateRuntimeError): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
165 """Raised if a template tries to operate on :class:`Undefined`.""" | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
166 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
167 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
168 class SecurityError(TemplateRuntimeError): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
169 """Raised if a template tries to do something insecure if the | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
170 sandbox is enabled. | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
171 """ | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
172 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
173 | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
174 class FilterArgumentError(TemplateRuntimeError): | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
175 """This error is raised if a filter was called with inappropriate | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
176 arguments | 
| 
 
26e78fe6e8c4
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
 
shellac 
parents:  
diff
changeset
 | 
177 """ | 
