Python jinja2.nodes.With() Examples

The following are 17 code examples of jinja2.nodes.With(). 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: parser.py    From Building-Recommendation-Systems-with-Python with MIT License 6 votes vote down vote up
def parse_with(self):
        node = nodes.With(lineno=next(self.stream).lineno)
        targets = []
        values = []
        while self.stream.current.type != 'block_end':
            lineno = self.stream.current.lineno
            if targets:
                self.stream.expect('comma')
            target = self.parse_assign_target()
            target.set_ctx('param')
            targets.append(target)
            self.stream.expect('assign')
            values.append(self.parse_expression())
        node.targets = targets
        node.values = values
        node.body = self.parse_statements(('name:endwith',),
                                          drop_needle=True)
        return node 
Example #2
Source File: parser.py    From android_universal with MIT License 6 votes vote down vote up
def parse_with(self):
        node = nodes.With(lineno=next(self.stream).lineno)
        targets = []
        values = []
        while self.stream.current.type != 'block_end':
            lineno = self.stream.current.lineno
            if targets:
                self.stream.expect('comma')
            target = self.parse_assign_target()
            target.set_ctx('param')
            targets.append(target)
            self.stream.expect('assign')
            values.append(self.parse_expression())
        node.targets = targets
        node.values = values
        node.body = self.parse_statements(('name:endwith',),
                                          drop_needle=True)
        return node 
Example #3
Source File: parser.py    From Carnets with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def parse_with(self):
        node = nodes.With(lineno=next(self.stream).lineno)
        targets = []
        values = []
        while self.stream.current.type != 'block_end':
            lineno = self.stream.current.lineno
            if targets:
                self.stream.expect('comma')
            target = self.parse_assign_target()
            target.set_ctx('param')
            targets.append(target)
            self.stream.expect('assign')
            values.append(self.parse_expression())
        node.targets = targets
        node.values = values
        node.body = self.parse_statements(('name:endwith',),
                                          drop_needle=True)
        return node 
Example #4
Source File: parser.py    From EDCOP with Apache License 2.0 6 votes vote down vote up
def parse_with(self):
        node = nodes.With(lineno=next(self.stream).lineno)
        targets = []
        values = []
        while self.stream.current.type != 'block_end':
            lineno = self.stream.current.lineno
            if targets:
                self.stream.expect('comma')
            target = self.parse_assign_target()
            target.set_ctx('param')
            targets.append(target)
            self.stream.expect('assign')
            values.append(self.parse_expression())
        node.targets = targets
        node.values = values
        node.body = self.parse_statements(('name:endwith',),
                                          drop_needle=True)
        return node 
Example #5
Source File: parser.py    From odoo13-x64 with GNU General Public License v3.0 6 votes vote down vote up
def parse_with(self):
        node = nodes.With(lineno=next(self.stream).lineno)
        targets = []
        values = []
        while self.stream.current.type != 'block_end':
            lineno = self.stream.current.lineno
            if targets:
                self.stream.expect('comma')
            target = self.parse_assign_target()
            target.set_ctx('param')
            targets.append(target)
            self.stream.expect('assign')
            values.append(self.parse_expression())
        node.targets = targets
        node.values = values
        node.body = self.parse_statements(('name:endwith',),
                                          drop_needle=True)
        return node 
Example #6
Source File: parser.py    From PhonePi_SampleServer with MIT License 6 votes vote down vote up
def parse_with(self):
        node = nodes.With(lineno=next(self.stream).lineno)
        targets = []
        values = []
        while self.stream.current.type != 'block_end':
            lineno = self.stream.current.lineno
            if targets:
                self.stream.expect('comma')
            target = self.parse_assign_target()
            target.set_ctx('param')
            targets.append(target)
            self.stream.expect('assign')
            values.append(self.parse_expression())
        node.targets = targets
        node.values = values
        node.body = self.parse_statements(('name:endwith',),
                                          drop_needle=True)
        return node 
Example #7
Source File: parser.py    From planespotter with MIT License 6 votes vote down vote up
def parse_with(self):
        node = nodes.With(lineno=next(self.stream).lineno)
        targets = []
        values = []
        while self.stream.current.type != 'block_end':
            lineno = self.stream.current.lineno
            if targets:
                self.stream.expect('comma')
            target = self.parse_assign_target()
            target.set_ctx('param')
            targets.append(target)
            self.stream.expect('assign')
            values.append(self.parse_expression())
        node.targets = targets
        node.values = values
        node.body = self.parse_statements(('name:endwith',),
                                          drop_needle=True)
        return node 
Example #8
Source File: parser.py    From cadquery-freecad-module with GNU Lesser General Public License v3.0 6 votes vote down vote up
def parse_with(self):
        node = nodes.With(lineno=next(self.stream).lineno)
        targets = []
        values = []
        while self.stream.current.type != 'block_end':
            lineno = self.stream.current.lineno
            if targets:
                self.stream.expect('comma')
            target = self.parse_assign_target()
            target.set_ctx('param')
            targets.append(target)
            self.stream.expect('assign')
            values.append(self.parse_expression())
        node.targets = targets
        node.values = values
        node.body = self.parse_statements(('name:endwith',),
                                          drop_needle=True)
        return node 
Example #9
Source File: parser.py    From scylla with Apache License 2.0 6 votes vote down vote up
def parse_with(self):
        node = nodes.With(lineno=next(self.stream).lineno)
        targets = []
        values = []
        while self.stream.current.type != 'block_end':
            lineno = self.stream.current.lineno
            if targets:
                self.stream.expect('comma')
            target = self.parse_assign_target()
            target.set_ctx('param')
            targets.append(target)
            self.stream.expect('assign')
            values.append(self.parse_expression())
        node.targets = targets
        node.values = values
        node.body = self.parse_statements(('name:endwith',),
                                          drop_needle=True)
        return node 
Example #10
Source File: parser.py    From misp42splunk with GNU Lesser General Public License v3.0 6 votes vote down vote up
def parse_with(self):
        node = nodes.With(lineno=next(self.stream).lineno)
        targets = []
        values = []
        while self.stream.current.type != 'block_end':
            lineno = self.stream.current.lineno
            if targets:
                self.stream.expect('comma')
            target = self.parse_assign_target()
            target.set_ctx('param')
            targets.append(target)
            self.stream.expect('assign')
            values.append(self.parse_expression())
        node.targets = targets
        node.values = values
        node.body = self.parse_statements(('name:endwith',),
                                          drop_needle=True)
        return node 
Example #11
Source File: parser.py    From Building-Recommendation-Systems-with-Python with MIT License 6 votes vote down vote up
def parse_with(self):
        node = nodes.With(lineno=next(self.stream).lineno)
        targets = []
        values = []
        while self.stream.current.type != 'block_end':
            lineno = self.stream.current.lineno
            if targets:
                self.stream.expect('comma')
            target = self.parse_assign_target()
            target.set_ctx('param')
            targets.append(target)
            self.stream.expect('assign')
            values.append(self.parse_expression())
        node.targets = targets
        node.values = values
        node.body = self.parse_statements(('name:endwith',),
                                          drop_needle=True)
        return node 
Example #12
Source File: parser.py    From pySINDy with MIT License 6 votes vote down vote up
def parse_with(self):
        node = nodes.With(lineno=next(self.stream).lineno)
        targets = []
        values = []
        while self.stream.current.type != 'block_end':
            lineno = self.stream.current.lineno
            if targets:
                self.stream.expect('comma')
            target = self.parse_assign_target()
            target.set_ctx('param')
            targets.append(target)
            self.stream.expect('assign')
            values.append(self.parse_expression())
        node.targets = targets
        node.values = values
        node.body = self.parse_statements(('name:endwith',),
                                          drop_needle=True)
        return node 
Example #13
Source File: parser.py    From OpenXR-SDK-Source with Apache License 2.0 6 votes vote down vote up
def parse_with(self):
        node = nodes.With(lineno=next(self.stream).lineno)
        targets = []
        values = []
        while self.stream.current.type != 'block_end':
            lineno = self.stream.current.lineno
            if targets:
                self.stream.expect('comma')
            target = self.parse_assign_target()
            target.set_ctx('param')
            targets.append(target)
            self.stream.expect('assign')
            values.append(self.parse_expression())
        node.targets = targets
        node.values = values
        node.body = self.parse_statements(('name:endwith',),
                                          drop_needle=True)
        return node 
Example #14
Source File: parser.py    From RSSNewsGAE with Apache License 2.0 6 votes vote down vote up
def parse_with(self):
        node = nodes.With(lineno=next(self.stream).lineno)
        targets = []
        values = []
        while self.stream.current.type != 'block_end':
            lineno = self.stream.current.lineno
            if targets:
                self.stream.expect('comma')
            target = self.parse_assign_target()
            target.set_ctx('param')
            targets.append(target)
            self.stream.expect('assign')
            values.append(self.parse_expression())
        node.targets = targets
        node.values = values
        node.body = self.parse_statements(('name:endwith',),
                                          drop_needle=True)
        return node 
Example #15
Source File: parser.py    From recruit with Apache License 2.0 6 votes vote down vote up
def parse_with(self):
        node = nodes.With(lineno=next(self.stream).lineno)
        targets = []
        values = []
        while self.stream.current.type != 'block_end':
            lineno = self.stream.current.lineno
            if targets:
                self.stream.expect('comma')
            target = self.parse_assign_target()
            target.set_ctx('param')
            targets.append(target)
            self.stream.expect('assign')
            values.append(self.parse_expression())
        node.targets = targets
        node.values = values
        node.body = self.parse_statements(('name:endwith',),
                                          drop_needle=True)
        return node 
Example #16
Source File: parser.py    From recruit with Apache License 2.0 6 votes vote down vote up
def parse_with(self):
        node = nodes.With(lineno=next(self.stream).lineno)
        targets = []
        values = []
        while self.stream.current.type != 'block_end':
            lineno = self.stream.current.lineno
            if targets:
                self.stream.expect('comma')
            target = self.parse_assign_target()
            target.set_ctx('param')
            targets.append(target)
            self.stream.expect('assign')
            values.append(self.parse_expression())
        node.targets = targets
        node.values = values
        node.body = self.parse_statements(('name:endwith',),
                                          drop_needle=True)
        return node 
Example #17
Source File: parser.py    From misp42splunk with GNU Lesser General Public License v3.0 6 votes vote down vote up
def parse_with(self):
        node = nodes.With(lineno=next(self.stream).lineno)
        targets = []
        values = []
        while self.stream.current.type != 'block_end':
            lineno = self.stream.current.lineno
            if targets:
                self.stream.expect('comma')
            target = self.parse_assign_target()
            target.set_ctx('param')
            targets.append(target)
            self.stream.expect('assign')
            values.append(self.parse_expression())
        node.targets = targets
        node.values = values
        node.body = self.parse_statements(('name:endwith',),
                                          drop_needle=True)
        return node