Python jinja2.runtime._last_iteration() Examples
The following are 30
code examples of jinja2.runtime._last_iteration().
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.runtime
, or try the search function
.
Example #1
Source File: asyncsupport.py From Building-Recommendation-Systems-with-Python with MIT License | 6 votes |
def make_async_loop_context(iterable, undefined, recurse=None, depth0=0): # Length is more complicated and less efficient in async mode. The # reason for this is that we cannot know if length will be used # upfront but because length is a property we cannot lazily execute it # later. This means that we need to buffer it up and measure :( # # We however only do this for actual iterators, not for async # iterators as blocking here does not seem like the best idea in the # world. try: length = len(iterable) except (TypeError, AttributeError): if not hasattr(iterable, '__aiter__'): iterable = tuple(iterable) length = len(iterable) else: length = None async_iterator = auto_aiter(iterable) try: after = await async_iterator.__anext__() except StopAsyncIteration: after = _last_iteration return AsyncLoopContext(async_iterator, undefined, after, length, recurse, depth0)
Example #2
Source File: asyncsupport.py From android_universal with MIT License | 6 votes |
def make_async_loop_context(iterable, undefined, recurse=None, depth0=0): # Length is more complicated and less efficient in async mode. The # reason for this is that we cannot know if length will be used # upfront but because length is a property we cannot lazily execute it # later. This means that we need to buffer it up and measure :( # # We however only do this for actual iterators, not for async # iterators as blocking here does not seem like the best idea in the # world. try: length = len(iterable) except (TypeError, AttributeError): if not hasattr(iterable, '__aiter__'): iterable = tuple(iterable) length = len(iterable) else: length = None async_iterator = auto_aiter(iterable) try: after = await async_iterator.__anext__() except StopAsyncIteration: after = _last_iteration return AsyncLoopContext(async_iterator, undefined, after, length, recurse, depth0)
Example #3
Source File: asyncsupport.py From Carnets with BSD 3-Clause "New" or "Revised" License | 6 votes |
def make_async_loop_context(iterable, undefined, recurse=None, depth0=0): # Length is more complicated and less efficient in async mode. The # reason for this is that we cannot know if length will be used # upfront but because length is a property we cannot lazily execute it # later. This means that we need to buffer it up and measure :( # # We however only do this for actual iterators, not for async # iterators as blocking here does not seem like the best idea in the # world. try: length = len(iterable) except (TypeError, AttributeError): if not hasattr(iterable, '__aiter__'): iterable = tuple(iterable) length = len(iterable) else: length = None async_iterator = auto_aiter(iterable) try: after = await async_iterator.__anext__() except StopAsyncIteration: after = _last_iteration return AsyncLoopContext(async_iterator, undefined, after, length, recurse, depth0)
Example #4
Source File: asyncsupport.py From EDCOP with Apache License 2.0 | 6 votes |
def make_async_loop_context(iterable, undefined, recurse=None, depth0=0): # Length is more complicated and less efficient in async mode. The # reason for this is that we cannot know if length will be used # upfront but because length is a property we cannot lazily execute it # later. This means that we need to buffer it up and measure :( # # We however only do this for actual iterators, not for async # iterators as blocking here does not seem like the best idea in the # world. try: length = len(iterable) except (TypeError, AttributeError): if not hasattr(iterable, '__aiter__'): iterable = tuple(iterable) length = len(iterable) else: length = None async_iterator = auto_aiter(iterable) try: after = await async_iterator.__anext__() except StopAsyncIteration: after = _last_iteration return AsyncLoopContext(async_iterator, undefined, after, length, recurse, depth0)
Example #5
Source File: asyncsupport.py From odoo13-x64 with GNU General Public License v3.0 | 6 votes |
def make_async_loop_context(iterable, undefined, recurse=None, depth0=0): # Length is more complicated and less efficient in async mode. The # reason for this is that we cannot know if length will be used # upfront but because length is a property we cannot lazily execute it # later. This means that we need to buffer it up and measure :( # # We however only do this for actual iterators, not for async # iterators as blocking here does not seem like the best idea in the # world. try: length = len(iterable) except (TypeError, AttributeError): if not hasattr(iterable, '__aiter__'): iterable = tuple(iterable) length = len(iterable) else: length = None async_iterator = auto_aiter(iterable) try: after = await async_iterator.__anext__() except StopAsyncIteration: after = _last_iteration return AsyncLoopContext(async_iterator, undefined, after, length, recurse, depth0)
Example #6
Source File: asyncsupport.py From PhonePi_SampleServer with MIT License | 6 votes |
def make_async_loop_context(iterable, recurse=None, depth0=0): # Length is more complicated and less efficient in async mode. The # reason for this is that we cannot know if length will be used # upfront but because length is a property we cannot lazily execute it # later. This means that we need to buffer it up and measure :( # # We however only do this for actual iterators, not for async # iterators as blocking here does not seem like the best idea in the # world. try: length = len(iterable) except (TypeError, AttributeError): if not hasattr(iterable, '__aiter__'): iterable = tuple(iterable) length = len(iterable) else: length = None async_iterator = auto_aiter(iterable) try: after = await async_iterator.__anext__() except StopAsyncIteration: after = _last_iteration return AsyncLoopContext(async_iterator, after, length, recurse, depth0)
Example #7
Source File: asyncsupport.py From planespotter with MIT License | 6 votes |
def make_async_loop_context(iterable, undefined, recurse=None, depth0=0): # Length is more complicated and less efficient in async mode. The # reason for this is that we cannot know if length will be used # upfront but because length is a property we cannot lazily execute it # later. This means that we need to buffer it up and measure :( # # We however only do this for actual iterators, not for async # iterators as blocking here does not seem like the best idea in the # world. try: length = len(iterable) except (TypeError, AttributeError): if not hasattr(iterable, '__aiter__'): iterable = tuple(iterable) length = len(iterable) else: length = None async_iterator = auto_aiter(iterable) try: after = await async_iterator.__anext__() except StopAsyncIteration: after = _last_iteration return AsyncLoopContext(async_iterator, undefined, after, length, recurse, depth0)
Example #8
Source File: asyncsupport.py From cadquery-freecad-module with GNU Lesser General Public License v3.0 | 6 votes |
def make_async_loop_context(iterable, undefined, recurse=None, depth0=0): # Length is more complicated and less efficient in async mode. The # reason for this is that we cannot know if length will be used # upfront but because length is a property we cannot lazily execute it # later. This means that we need to buffer it up and measure :( # # We however only do this for actual iterators, not for async # iterators as blocking here does not seem like the best idea in the # world. try: length = len(iterable) except (TypeError, AttributeError): if not hasattr(iterable, '__aiter__'): iterable = tuple(iterable) length = len(iterable) else: length = None async_iterator = auto_aiter(iterable) try: after = await async_iterator.__anext__() except StopAsyncIteration: after = _last_iteration return AsyncLoopContext(async_iterator, undefined, after, length, recurse, depth0)
Example #9
Source File: asyncsupport.py From scylla with Apache License 2.0 | 6 votes |
def make_async_loop_context(iterable, undefined, recurse=None, depth0=0): # Length is more complicated and less efficient in async mode. The # reason for this is that we cannot know if length will be used # upfront but because length is a property we cannot lazily execute it # later. This means that we need to buffer it up and measure :( # # We however only do this for actual iterators, not for async # iterators as blocking here does not seem like the best idea in the # world. try: length = len(iterable) except (TypeError, AttributeError): if not hasattr(iterable, '__aiter__'): iterable = tuple(iterable) length = len(iterable) else: length = None async_iterator = auto_aiter(iterable) try: after = await async_iterator.__anext__() except StopAsyncIteration: after = _last_iteration return AsyncLoopContext(async_iterator, undefined, after, length, recurse, depth0)
Example #10
Source File: asyncsupport.py From Building-Recommendation-Systems-with-Python with MIT License | 6 votes |
def make_async_loop_context(iterable, undefined, recurse=None, depth0=0): # Length is more complicated and less efficient in async mode. The # reason for this is that we cannot know if length will be used # upfront but because length is a property we cannot lazily execute it # later. This means that we need to buffer it up and measure :( # # We however only do this for actual iterators, not for async # iterators as blocking here does not seem like the best idea in the # world. try: length = len(iterable) except (TypeError, AttributeError): if not hasattr(iterable, '__aiter__'): iterable = tuple(iterable) length = len(iterable) else: length = None async_iterator = auto_aiter(iterable) try: after = await async_iterator.__anext__() except StopAsyncIteration: after = _last_iteration return AsyncLoopContext(async_iterator, undefined, after, length, recurse, depth0)
Example #11
Source File: asyncsupport.py From pySINDy with MIT License | 6 votes |
def make_async_loop_context(iterable, undefined, recurse=None, depth0=0): # Length is more complicated and less efficient in async mode. The # reason for this is that we cannot know if length will be used # upfront but because length is a property we cannot lazily execute it # later. This means that we need to buffer it up and measure :( # # We however only do this for actual iterators, not for async # iterators as blocking here does not seem like the best idea in the # world. try: length = len(iterable) except (TypeError, AttributeError): if not hasattr(iterable, '__aiter__'): iterable = tuple(iterable) length = len(iterable) else: length = None async_iterator = auto_aiter(iterable) try: after = await async_iterator.__anext__() except StopAsyncIteration: after = _last_iteration return AsyncLoopContext(async_iterator, undefined, after, length, recurse, depth0)
Example #12
Source File: asyncsupport.py From misp42splunk with GNU Lesser General Public License v3.0 | 6 votes |
def make_async_loop_context(iterable, undefined, recurse=None, depth0=0): # Length is more complicated and less efficient in async mode. The # reason for this is that we cannot know if length will be used # upfront but because length is a property we cannot lazily execute it # later. This means that we need to buffer it up and measure :( # # We however only do this for actual iterators, not for async # iterators as blocking here does not seem like the best idea in the # world. try: length = len(iterable) except (TypeError, AttributeError): if not hasattr(iterable, '__aiter__'): iterable = tuple(iterable) length = len(iterable) else: length = None async_iterator = auto_aiter(iterable) try: after = await async_iterator.__anext__() except StopAsyncIteration: after = _last_iteration return AsyncLoopContext(async_iterator, undefined, after, length, recurse, depth0)
Example #13
Source File: asyncsupport.py From RSSNewsGAE with Apache License 2.0 | 6 votes |
def make_async_loop_context(iterable, recurse=None, depth0=0): # Length is more complicated and less efficient in async mode. The # reason for this is that we cannot know if length will be used # upfront but because length is a property we cannot lazily execute it # later. This means that we need to buffer it up and measure :( # # We however only do this for actual iterators, not for async # iterators as blocking here does not seem like the best idea in the # world. try: length = len(iterable) except (TypeError, AttributeError): if not hasattr(iterable, '__aiter__'): iterable = tuple(iterable) length = len(iterable) else: length = None async_iterator = auto_aiter(iterable) try: after = await async_iterator.__anext__() except StopAsyncIteration: after = _last_iteration return AsyncLoopContext(async_iterator, after, length, recurse, depth0)
Example #14
Source File: asyncsupport.py From misp42splunk with GNU Lesser General Public License v3.0 | 6 votes |
def make_async_loop_context(iterable, undefined, recurse=None, depth0=0): # Length is more complicated and less efficient in async mode. The # reason for this is that we cannot know if length will be used # upfront but because length is a property we cannot lazily execute it # later. This means that we need to buffer it up and measure :( # # We however only do this for actual iterators, not for async # iterators as blocking here does not seem like the best idea in the # world. try: length = len(iterable) except (TypeError, AttributeError): if not hasattr(iterable, '__aiter__'): iterable = tuple(iterable) length = len(iterable) else: length = None async_iterator = auto_aiter(iterable) try: after = await async_iterator.__anext__() except StopAsyncIteration: after = _last_iteration return AsyncLoopContext(async_iterator, undefined, after, length, recurse, depth0)
Example #15
Source File: asyncsupport.py From recruit with Apache License 2.0 | 6 votes |
def make_async_loop_context(iterable, undefined, recurse=None, depth0=0): # Length is more complicated and less efficient in async mode. The # reason for this is that we cannot know if length will be used # upfront but because length is a property we cannot lazily execute it # later. This means that we need to buffer it up and measure :( # # We however only do this for actual iterators, not for async # iterators as blocking here does not seem like the best idea in the # world. try: length = len(iterable) except (TypeError, AttributeError): if not hasattr(iterable, '__aiter__'): iterable = tuple(iterable) length = len(iterable) else: length = None async_iterator = auto_aiter(iterable) try: after = await async_iterator.__anext__() except StopAsyncIteration: after = _last_iteration return AsyncLoopContext(async_iterator, undefined, after, length, recurse, depth0)
Example #16
Source File: asyncsupport.py From OpenXR-SDK-Source with Apache License 2.0 | 6 votes |
def make_async_loop_context(iterable, undefined, recurse=None, depth0=0): # Length is more complicated and less efficient in async mode. The # reason for this is that we cannot know if length will be used # upfront but because length is a property we cannot lazily execute it # later. This means that we need to buffer it up and measure :( # # We however only do this for actual iterators, not for async # iterators as blocking here does not seem like the best idea in the # world. try: length = len(iterable) except (TypeError, AttributeError): if not hasattr(iterable, '__aiter__'): iterable = tuple(iterable) length = len(iterable) else: length = None async_iterator = auto_aiter(iterable) try: after = await async_iterator.__anext__() except StopAsyncIteration: after = _last_iteration return AsyncLoopContext(async_iterator, undefined, after, length, recurse, depth0)
Example #17
Source File: asyncsupport.py From recruit with Apache License 2.0 | 6 votes |
def make_async_loop_context(iterable, undefined, recurse=None, depth0=0): # Length is more complicated and less efficient in async mode. The # reason for this is that we cannot know if length will be used # upfront but because length is a property we cannot lazily execute it # later. This means that we need to buffer it up and measure :( # # We however only do this for actual iterators, not for async # iterators as blocking here does not seem like the best idea in the # world. try: length = len(iterable) except (TypeError, AttributeError): if not hasattr(iterable, '__aiter__'): iterable = tuple(iterable) length = len(iterable) else: length = None async_iterator = auto_aiter(iterable) try: after = await async_iterator.__anext__() except StopAsyncIteration: after = _last_iteration return AsyncLoopContext(async_iterator, undefined, after, length, recurse, depth0)
Example #18
Source File: asyncsupport.py From planespotter with MIT License | 5 votes |
def __anext__(self): ctx = self.context ctx.index0 += 1 if ctx._after is _last_iteration: raise StopAsyncIteration() ctx._before = ctx._current ctx._current = ctx._after try: ctx._after = await ctx._async_iterator.__anext__() except StopAsyncIteration: ctx._after = _last_iteration return ctx._current, ctx
Example #19
Source File: asyncsupport.py From android_universal with MIT License | 5 votes |
def __anext__(self): ctx = self.context ctx.index0 += 1 if ctx._after is _last_iteration: raise StopAsyncIteration() ctx._before = ctx._current ctx._current = ctx._after try: ctx._after = await ctx._async_iterator.__anext__() except StopAsyncIteration: ctx._after = _last_iteration return ctx._current, ctx
Example #20
Source File: asyncsupport.py From misp42splunk with GNU Lesser General Public License v3.0 | 5 votes |
def __anext__(self): ctx = self.context ctx.index0 += 1 if ctx._after is _last_iteration: raise StopAsyncIteration() ctx._before = ctx._current ctx._current = ctx._after try: ctx._after = await ctx._async_iterator.__anext__() except StopAsyncIteration: ctx._after = _last_iteration return ctx._current, ctx
Example #21
Source File: asyncsupport.py From Carnets with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __anext__(self): ctx = self.context ctx.index0 += 1 if ctx._after is _last_iteration: raise StopAsyncIteration() ctx._before = ctx._current ctx._current = ctx._after try: ctx._after = await ctx._async_iterator.__anext__() except StopAsyncIteration: ctx._after = _last_iteration return ctx._current, ctx
Example #22
Source File: asyncsupport.py From EDCOP with Apache License 2.0 | 5 votes |
def __anext__(self): ctx = self.context ctx.index0 += 1 if ctx._after is _last_iteration: raise StopAsyncIteration() ctx._before = ctx._current ctx._current = ctx._after try: ctx._after = await ctx._async_iterator.__anext__() except StopAsyncIteration: ctx._after = _last_iteration return ctx._current, ctx
Example #23
Source File: asyncsupport.py From recruit with Apache License 2.0 | 5 votes |
def __anext__(self): ctx = self.context ctx.index0 += 1 if ctx._after is _last_iteration: raise StopAsyncIteration() ctx._before = ctx._current ctx._current = ctx._after try: ctx._after = await ctx._async_iterator.__anext__() except StopAsyncIteration: ctx._after = _last_iteration return ctx._current, ctx
Example #24
Source File: asyncsupport.py From odoo13-x64 with GNU General Public License v3.0 | 5 votes |
def __anext__(self): ctx = self.context ctx.index0 += 1 if ctx._after is _last_iteration: raise StopAsyncIteration() ctx._before = ctx._current ctx._current = ctx._after try: ctx._after = await ctx._async_iterator.__anext__() except StopAsyncIteration: ctx._after = _last_iteration return ctx._current, ctx
Example #25
Source File: asyncsupport.py From PhonePi_SampleServer with MIT License | 5 votes |
def __anext__(self): ctx = self.context ctx.index0 += 1 if ctx._after is _last_iteration: raise StopAsyncIteration() next_elem = ctx._after try: ctx._after = await ctx._async_iterator.__anext__() except StopAsyncIteration: ctx._after = _last_iteration return next_elem, ctx
Example #26
Source File: asyncsupport.py From recruit with Apache License 2.0 | 5 votes |
def __anext__(self): ctx = self.context ctx.index0 += 1 if ctx._after is _last_iteration: raise StopAsyncIteration() ctx._before = ctx._current ctx._current = ctx._after try: ctx._after = await ctx._async_iterator.__anext__() except StopAsyncIteration: ctx._after = _last_iteration return ctx._current, ctx
Example #27
Source File: asyncsupport.py From cadquery-freecad-module with GNU Lesser General Public License v3.0 | 5 votes |
def __anext__(self): ctx = self.context ctx.index0 += 1 if ctx._after is _last_iteration: raise StopAsyncIteration() ctx._before = ctx._current ctx._current = ctx._after try: ctx._after = await ctx._async_iterator.__anext__() except StopAsyncIteration: ctx._after = _last_iteration return ctx._current, ctx
Example #28
Source File: asyncsupport.py From RSSNewsGAE with Apache License 2.0 | 5 votes |
def __anext__(self): ctx = self.context ctx.index0 += 1 if ctx._after is _last_iteration: raise StopAsyncIteration() next_elem = ctx._after try: ctx._after = await ctx._async_iterator.__anext__() except StopAsyncIteration: ctx._after = _last_iteration return next_elem, ctx
Example #29
Source File: asyncsupport.py From scylla with Apache License 2.0 | 5 votes |
def __anext__(self): ctx = self.context ctx.index0 += 1 if ctx._after is _last_iteration: raise StopAsyncIteration() ctx._before = ctx._current ctx._current = ctx._after try: ctx._after = await ctx._async_iterator.__anext__() except StopAsyncIteration: ctx._after = _last_iteration return ctx._current, ctx
Example #30
Source File: asyncsupport.py From misp42splunk with GNU Lesser General Public License v3.0 | 5 votes |
def __anext__(self): ctx = self.context ctx.index0 += 1 if ctx._after is _last_iteration: raise StopAsyncIteration() ctx._before = ctx._current ctx._current = ctx._after try: ctx._after = await ctx._async_iterator.__anext__() except StopAsyncIteration: ctx._after = _last_iteration return ctx._current, ctx