async 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
async 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
def __select_or_reject_attr_if_present_key(args, kwargs, modfunc, lookup_attr): """ Processes the select or reject filter only if the attribute exists. Parameters: args (list): The arguments to process. args[0] (any): The context of the Template. args[1] (any): The collection. args[2] (str): The attribute to use in the collection. args[3+] (str): Parameters for the Test function. modefunc (lambda): Function to use for the collection, used for inversing. lookup_attr (bool): Flag for if a particular attribute in the item should be used. Returns: List of items that either match the test function or do not contain the specified attribute. """ seq, func = prepare_select_or_reject(args, kwargs, modfunc, lookup_attr) if seq: for item in seq: if args[2] in item.keys(): if func(item): yield item else: yield item