Add load_all_users

This commit is contained in:
Tim Van Baak 2020-04-24 10:52:13 -07:00
parent 46f7b54556
commit 6d0aa3eb34
2 changed files with 21 additions and 0 deletions

View File

@ -1,9 +1,11 @@
from amanuensis.user.manage import load_all_users
from amanuensis.user.signup import ( from amanuensis.user.signup import (
create_user, create_user,
valid_username, valid_username,
valid_email) valid_email)
__all__ = [member.__name__ for member in [ __all__ = [member.__name__ for member in [
load_all_users,
create_user, create_user,
valid_username, valid_username,
valid_email, valid_email,

19
amanuensis/user/manage.py Normal file
View File

@ -0,0 +1,19 @@
"""
General functions for managing users
"""
from typing import Iterable
from amanuensis.config import RootConfigDirectoryContext
from amanuensis.models import ModelFactory, UserModel
def load_all_users(
root: RootConfigDirectoryContext) -> Iterable[UserModel]:
"""
Iterably loads every lexicon in the config store
"""
model_factory: ModelFactory = ModelFactory(root)
with root.user.read_index() as index:
for uid in index.values():
user: UserModel = model_factory.user(uid)
yield user