本文整理匯總了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