feat(FastAPI): add aurweb.util.apply_all(iterable, fn)

A helper which allows us to apply a specific function to each
item in an iterable.

Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
Kevin Morris 2021-09-19 19:27:29 -07:00
parent 16d516c221
commit c8d01cc5e8
No known key found for this signature in database
GPG key ID: F7E46DED420788F3

View file

@ -7,7 +7,7 @@ import secrets
import string
from datetime import datetime
from typing import Any, Dict
from typing import Any, Callable, Dict, Iterable
from urllib.parse import urlencode, urlparse
from zoneinfo import ZoneInfo
@ -167,3 +167,8 @@ def add_samesite_fields(response: Response, value: str):
def get_ssh_fingerprints():
return aurweb.config.get_section("fingerprints") or {}
def apply_all(iterable: Iterable, fn: Callable):
for item in iterable:
fn(item)