本文整理汇总了Python中jinja2.asyncsupport.auto_aiter方法的典型用法代码示例。如果您正苦于以下问题:Python asyncsupport.auto_aiter方法的具体用法?Python asyncsupport.auto_aiter怎么用?Python asyncsupport.auto_aiter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jinja2.asyncsupport
的用法示例。
在下文中一共展示了asyncsupport.auto_aiter方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: async_select_or_reject
# 需要导入模块: from jinja2 import asyncsupport [as 别名]
# 或者: from jinja2.asyncsupport import auto_aiter [as 别名]
def async_select_or_reject(args, kwargs, modfunc, lookup_attr):
seq, func = filters.prepare_select_or_reject(
args, kwargs, modfunc, lookup_attr)
if seq:
async for item in auto_aiter(seq):
if func(item):
yield item
示例2: do_first
# 需要导入模块: from jinja2 import asyncsupport [as 别名]
# 或者: from jinja2.asyncsupport import auto_aiter [as 别名]
def do_first(environment, seq):
try:
return await auto_aiter(seq).__anext__()
except StopAsyncIteration:
return environment.undefined('No first item, sequence was empty.')
示例3: do_map
# 需要导入模块: from jinja2 import asyncsupport [as 别名]
# 或者: from jinja2.asyncsupport import auto_aiter [as 别名]
def do_map(*args, **kwargs):
seq, func = filters.prepare_map(args, kwargs)
if seq:
async for item in auto_aiter(seq):
yield func(item)
示例4: do_sum
# 需要导入模块: from jinja2 import asyncsupport [as 别名]
# 或者: from jinja2.asyncsupport import auto_aiter [as 别名]
def do_sum(environment, iterable, attribute=None, start=0):
rv = start
if attribute is not None:
func = filters.make_attrgetter(environment, attribute)
else:
func = lambda x: x
async for item in auto_aiter(iterable):
rv += func(item)
return rv