Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: third_party/jinja2/nodes.py

Issue 2316103002: binding: Updates Jinja2 from 2.7.1 to 2.8. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/jinja2/meta.py ('k') | third_party/jinja2/parser.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # -*- coding: utf-8 -*- 1 # -*- coding: utf-8 -*-
2 """ 2 """
3 jinja2.nodes 3 jinja2.nodes
4 ~~~~~~~~~~~~ 4 ~~~~~~~~~~~~
5 5
6 This module implements additional nodes derived from the ast base node. 6 This module implements additional nodes derived from the ast base node.
7 7
8 It also provides some node tree helper functions like `in_lineno` and 8 It also provides some node tree helper functions like `in_lineno` and
9 `get_nodes` used by the parser and translator in order to normalize 9 `get_nodes` used by the parser and translator in order to normalize
10 python and jinja nodes. 10 python and jinja nodes.
11 11
12 :copyright: (c) 2010 by the Jinja Team. 12 :copyright: (c) 2010 by the Jinja Team.
13 :license: BSD, see LICENSE for more details. 13 :license: BSD, see LICENSE for more details.
14 """ 14 """
15 import types
15 import operator 16 import operator
16 17
17 from collections import deque 18 from collections import deque
18 from jinja2.utils import Markup 19 from jinja2.utils import Markup
19 from jinja2._compat import next, izip, with_metaclass, text_type, \ 20 from jinja2._compat import izip, with_metaclass, text_type
20 method_type, function_type
21 21
22 22
23 #: the types we support for context functions 23 #: the types we support for context functions
24 _context_function_types = (function_type, method_type) 24 _context_function_types = (types.FunctionType, types.MethodType)
25 25
26 26
27 _binop_to_func = { 27 _binop_to_func = {
28 '*': operator.mul, 28 '*': operator.mul,
29 '/': operator.truediv, 29 '/': operator.truediv,
30 '//': operator.floordiv, 30 '//': operator.floordiv,
31 '**': operator.pow, 31 '**': operator.pow,
32 '%': operator.mod, 32 '%': operator.mod,
33 '+': operator.add, 33 '+': operator.add,
34 '-': operator.sub 34 '-': operator.sub
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 class ExprStmt(Stmt): 340 class ExprStmt(Stmt):
341 """A statement that evaluates an expression and discards the result.""" 341 """A statement that evaluates an expression and discards the result."""
342 fields = ('node',) 342 fields = ('node',)
343 343
344 344
345 class Assign(Stmt): 345 class Assign(Stmt):
346 """Assigns an expression to a target.""" 346 """Assigns an expression to a target."""
347 fields = ('target', 'node') 347 fields = ('target', 'node')
348 348
349 349
350 class AssignBlock(Stmt):
351 """Assigns a block to a target."""
352 fields = ('target', 'body')
353
354
350 class Expr(Node): 355 class Expr(Node):
351 """Baseclass for all expressions.""" 356 """Baseclass for all expressions."""
352 abstract = True 357 abstract = True
353 358
354 def as_const(self, eval_ctx=None): 359 def as_const(self, eval_ctx=None):
355 """Return the value of the expression as constant or raise 360 """Return the value of the expression as constant or raise
356 :exc:`Impossible` if this was not possible. 361 :exc:`Impossible` if this was not possible.
357 362
358 An :class:`EvalContext` can be provided, if none is given 363 An :class:`EvalContext` can be provided, if none is given
359 a default context is created which requires the nodes to have 364 a default context is created which requires the nodes to have
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 """ 744 """
740 operator = '//' 745 operator = '//'
741 746
742 747
743 class Add(BinExpr): 748 class Add(BinExpr):
744 """Add the left to the right node.""" 749 """Add the left to the right node."""
745 operator = '+' 750 operator = '+'
746 751
747 752
748 class Sub(BinExpr): 753 class Sub(BinExpr):
749 """Substract the right from the left node.""" 754 """Subtract the right from the left node."""
750 operator = '-' 755 operator = '-'
751 756
752 757
753 class Mod(BinExpr): 758 class Mod(BinExpr):
754 """Left modulo right.""" 759 """Left modulo right."""
755 operator = '%' 760 operator = '%'
756 761
757 762
758 class Pow(BinExpr): 763 class Pow(BinExpr):
759 """Left to the power of right.""" 764 """Left to the power of right."""
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 :class:`EvalContextModifier` but will only modify the 910 :class:`EvalContextModifier` but will only modify the
906 :class:`~jinja2.nodes.EvalContext` for nodes in the :attr:`body`. 911 :class:`~jinja2.nodes.EvalContext` for nodes in the :attr:`body`.
907 """ 912 """
908 fields = ('body',) 913 fields = ('body',)
909 914
910 915
911 # make sure nobody creates custom nodes 916 # make sure nobody creates custom nodes
912 def _failing_new(*args, **kwargs): 917 def _failing_new(*args, **kwargs):
913 raise TypeError('can\'t create custom node types') 918 raise TypeError('can\'t create custom node types')
914 NodeType.__new__ = staticmethod(_failing_new); del _failing_new 919 NodeType.__new__ = staticmethod(_failing_new); del _failing_new
OLDNEW
« no previous file with comments | « third_party/jinja2/meta.py ('k') | third_party/jinja2/parser.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698