Python jinja2.nodes.Impossible() Examples
The following are 30
code examples of jinja2.nodes.Impossible().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
jinja2.nodes
, or try the search function
.
Example #1
Source File: optimizer.py From jbox with MIT License | 6 votes |
def visit_If(self, node): """Eliminate dead code.""" # do not optimize ifs that have a block inside so that it doesn't # break super(). if node.find(nodes.Block) is not None: return self.generic_visit(node) try: val = self.visit(node.test).as_const() except nodes.Impossible: return self.generic_visit(node) if val: body = node.body else: body = node.else_ result = [] for node in body: result.extend(self.visit_list(node)) return result
Example #2
Source File: optimizer.py From luci-py with Apache License 2.0 | 6 votes |
def visit_If(self, node): """Eliminate dead code.""" # do not optimize ifs that have a block inside so that it doesn't # break super(). if node.find(nodes.Block) is not None: return self.generic_visit(node) try: val = self.visit(node.test).as_const() except nodes.Impossible: return self.generic_visit(node) if val: body = node.body else: body = node.else_ result = [] for node in body: result.extend(self.visit_list(node)) return result
Example #3
Source File: optimizer.py From luci-py with Apache License 2.0 | 6 votes |
def visit_If(self, node): """Eliminate dead code.""" # do not optimize ifs that have a block inside so that it doesn't # break super(). if node.find(nodes.Block) is not None: return self.generic_visit(node) try: val = self.visit(node.test).as_const() except nodes.Impossible: return self.generic_visit(node) if val: body = node.body else: body = node.else_ result = [] for node in body: result.extend(self.visit_list(node)) return result
Example #4
Source File: optimizer.py From syntheticmass with Apache License 2.0 | 6 votes |
def visit_If(self, node): """Eliminate dead code.""" # do not optimize ifs that have a block inside so that it doesn't # break super(). if node.find(nodes.Block) is not None: return self.generic_visit(node) try: val = self.visit(node.test).as_const() except nodes.Impossible: return self.generic_visit(node) if val: body = node.body else: body = node.else_ result = [] for node in body: result.extend(self.visit_list(node)) return result
Example #5
Source File: optimizer.py From luci-py with Apache License 2.0 | 6 votes |
def visit_If(self, node): """Eliminate dead code.""" # do not optimize ifs that have a block inside so that it doesn't # break super(). if node.find(nodes.Block) is not None: return self.generic_visit(node) try: val = self.visit(node.test).as_const() except nodes.Impossible: return self.generic_visit(node) if val: body = node.body else: body = node.else_ result = [] for node in body: result.extend(self.visit_list(node)) return result
Example #6
Source File: optimizer.py From luci-py with Apache License 2.0 | 6 votes |
def visit_If(self, node): """Eliminate dead code.""" # do not optimize ifs that have a block inside so that it doesn't # break super(). if node.find(nodes.Block) is not None: return self.generic_visit(node) try: val = self.visit(node.test).as_const() except nodes.Impossible: return self.generic_visit(node) if val: body = node.body else: body = node.else_ result = [] for node in body: result.extend(self.visit_list(node)) return result
Example #7
Source File: optimizer.py From Financial-Portfolio-Flask with MIT License | 6 votes |
def visit_If(self, node): """Eliminate dead code.""" # do not optimize ifs that have a block inside so that it doesn't # break super(). if node.find(nodes.Block) is not None: return self.generic_visit(node) try: val = self.visit(node.test).as_const() except nodes.Impossible: return self.generic_visit(node) if val: body = node.body else: body = node.else_ result = [] for node in body: result.extend(self.visit_list(node)) return result
Example #8
Source File: optimizer.py From SA-ctf_scoreboard with Creative Commons Zero v1.0 Universal | 6 votes |
def visit_If(self, node): """Eliminate dead code.""" # do not optimize ifs that have a block inside so that it doesn't # break super(). if node.find(nodes.Block) is not None: return self.generic_visit(node) try: val = self.visit(node.test).as_const() except nodes.Impossible: return self.generic_visit(node) if val: body = node.body else: body = node.else_ result = [] for node in body: result.extend(self.visit_list(node)) return result
Example #9
Source File: optimizer.py From luci-py with Apache License 2.0 | 6 votes |
def visit_If(self, node): """Eliminate dead code.""" # do not optimize ifs that have a block inside so that it doesn't # break super(). if node.find(nodes.Block) is not None: return self.generic_visit(node) try: val = self.visit(node.test).as_const() except nodes.Impossible: return self.generic_visit(node) if val: body = node.body else: body = node.else_ result = [] for node in body: result.extend(self.visit_list(node)) return result
Example #10
Source File: optimizer.py From Flask-P2P with MIT License | 6 votes |
def visit_If(self, node): """Eliminate dead code.""" # do not optimize ifs that have a block inside so that it doesn't # break super(). if node.find(nodes.Block) is not None: return self.generic_visit(node) try: val = self.visit(node.test).as_const() except nodes.Impossible: return self.generic_visit(node) if val: body = node.body else: body = node.else_ result = [] for node in body: result.extend(self.visit_list(node)) return result
Example #11
Source File: optimizer.py From data with GNU General Public License v3.0 | 6 votes |
def visit_If(self, node): """Eliminate dead code.""" # do not optimize ifs that have a block inside so that it doesn't # break super(). if node.find(nodes.Block) is not None: return self.generic_visit(node) try: val = self.visit(node.test).as_const() except nodes.Impossible: return self.generic_visit(node) if val: body = node.body else: body = node.else_ result = [] for node in body: result.extend(self.visit_list(node)) return result
Example #12
Source File: compiler.py From odoo13-x64 with GNU General Public License v3.0 | 5 votes |
def visit_EvalContextModifier(self, node, frame): for keyword in node.options: self.writeline('context.eval_ctx.%s = ' % keyword.key) self.visit(keyword.value, frame) try: val = keyword.value.as_const(frame.eval_ctx) except nodes.Impossible: frame.eval_ctx.volatile = True else: setattr(frame.eval_ctx, keyword.key, val)
Example #13
Source File: compiler.py From odoo13-x64 with GNU General Public License v3.0 | 5 votes |
def visit_TemplateData(self, node, frame): try: self.write(repr(node.as_const(frame.eval_ctx))) except nodes.Impossible: self.write('(Markup if context.eval_ctx.autoescape else identity)(%r)' % node.data)
Example #14
Source File: compiler.py From EDCOP with Apache License 2.0 | 5 votes |
def visit_TemplateData(self, node, frame): try: self.write(repr(node.as_const(frame.eval_ctx))) except nodes.Impossible: self.write('(Markup if context.eval_ctx.autoescape else identity)(%r)' % node.data)
Example #15
Source File: compiler.py From SA-ctf_scoreboard with Creative Commons Zero v1.0 Universal | 5 votes |
def visit_EvalContextModifier(self, node, frame): for keyword in node.options: self.writeline('context.eval_ctx.%s = ' % keyword.key) self.visit(keyword.value, frame) try: val = keyword.value.as_const(frame.eval_ctx) except nodes.Impossible: frame.eval_ctx.volatile = True else: setattr(frame.eval_ctx, keyword.key, val)
Example #16
Source File: compiler.py From luci-py with Apache License 2.0 | 5 votes |
def visit_TemplateData(self, node, frame): try: self.write(repr(node.as_const(frame.eval_ctx))) except nodes.Impossible: self.write('(context.eval_ctx.autoescape and Markup or identity)(%r)' % node.data)
Example #17
Source File: optimizer.py From SA-ctf_scoreboard with Creative Commons Zero v1.0 Universal | 5 votes |
def fold(self, node): """Do constant folding.""" node = self.generic_visit(node) try: return nodes.Const.from_untrusted(node.as_const(), lineno=node.lineno, environment=self.environment) except nodes.Impossible: return node
Example #18
Source File: compiler.py From SA-ctf_scoreboard with Creative Commons Zero v1.0 Universal | 5 votes |
def visit_TemplateData(self, node, frame): try: self.write(repr(node.as_const(frame.eval_ctx))) except nodes.Impossible: self.write('(context.eval_ctx.autoescape and Markup or identity)(%r)' % node.data)
Example #19
Source File: optimizer.py From planespotter with MIT License | 5 votes |
def fold(self, node, eval_ctx=None): """Do constant folding.""" node = self.generic_visit(node) try: return nodes.Const.from_untrusted(node.as_const(eval_ctx), lineno=node.lineno, environment=self.environment) except nodes.Impossible: return node
Example #20
Source File: optimizer.py From luci-py with Apache License 2.0 | 5 votes |
def fold(self, node): """Do constant folding.""" node = self.generic_visit(node) try: return nodes.Const.from_untrusted(node.as_const(), lineno=node.lineno, environment=self.environment) except nodes.Impossible: return node
Example #21
Source File: compiler.py From luci-py with Apache License 2.0 | 5 votes |
def visit_TemplateData(self, node, frame): try: self.write(repr(node.as_const(frame.eval_ctx))) except nodes.Impossible: self.write('(context.eval_ctx.autoescape and Markup or identity)(%r)' % node.data)
Example #22
Source File: optimizer.py From luci-py with Apache License 2.0 | 5 votes |
def fold(self, node): """Do constant folding.""" node = self.generic_visit(node) try: return nodes.Const.from_untrusted(node.as_const(), lineno=node.lineno, environment=self.environment) except nodes.Impossible: return node
Example #23
Source File: compiler.py From luci-py with Apache License 2.0 | 5 votes |
def visit_EvalContextModifier(self, node, frame): for keyword in node.options: self.writeline('context.eval_ctx.%s = ' % keyword.key) self.visit(keyword.value, frame) try: val = keyword.value.as_const(frame.eval_ctx) except nodes.Impossible: frame.eval_ctx.volatile = True else: setattr(frame.eval_ctx, keyword.key, val)
Example #24
Source File: compiler.py From luci-py with Apache License 2.0 | 5 votes |
def visit_TemplateData(self, node, frame): try: self.write(repr(node.as_const(frame.eval_ctx))) except nodes.Impossible: self.write('(context.eval_ctx.autoescape and Markup or identity)(%r)' % node.data)
Example #25
Source File: compiler.py From luci-py with Apache License 2.0 | 5 votes |
def visit_EvalContextModifier(self, node, frame): for keyword in node.options: self.writeline('context.eval_ctx.%s = ' % keyword.key) self.visit(keyword.value, frame) try: val = keyword.value.as_const(frame.eval_ctx) except nodes.Impossible: frame.eval_ctx.volatile = True else: setattr(frame.eval_ctx, keyword.key, val)
Example #26
Source File: compiler.py From luci-py with Apache License 2.0 | 5 votes |
def visit_TemplateData(self, node, frame): try: self.write(repr(node.as_const(frame.eval_ctx))) except nodes.Impossible: self.write('(context.eval_ctx.autoescape and Markup or identity)(%r)' % node.data)
Example #27
Source File: optimizer.py From luci-py with Apache License 2.0 | 5 votes |
def fold(self, node): """Do constant folding.""" node = self.generic_visit(node) try: return nodes.Const.from_untrusted(node.as_const(), lineno=node.lineno, environment=self.environment) except nodes.Impossible: return node
Example #28
Source File: compiler.py From planespotter with MIT License | 5 votes |
def visit_EvalContextModifier(self, node, frame): for keyword in node.options: self.writeline('context.eval_ctx.%s = ' % keyword.key) self.visit(keyword.value, frame) try: val = keyword.value.as_const(frame.eval_ctx) except nodes.Impossible: frame.eval_ctx.volatile = True else: setattr(frame.eval_ctx, keyword.key, val)
Example #29
Source File: compiler.py From planespotter with MIT License | 5 votes |
def visit_TemplateData(self, node, frame): try: self.write(repr(node.as_const(frame.eval_ctx))) except nodes.Impossible: self.write('(Markup if context.eval_ctx.autoescape else identity)(%r)' % node.data)
Example #30
Source File: compiler.py From Flask-P2P with MIT License | 5 votes |
def visit_TemplateData(self, node, frame): try: self.write(repr(node.as_const(frame.eval_ctx))) except nodes.Impossible: self.write('(context.eval_ctx.autoescape and Markup or identity)(%r)' % node.data)