From 6d0aa3eb34638611e49c7915ce70aaa7854e0506 Mon Sep 17 00:00:00 2001 From: Tim Van Baak Date: Fri, 24 Apr 2020 10:52:13 -0700 Subject: [PATCH] Add load_all_users --- amanuensis/user/__init__.py | 2 ++ amanuensis/user/manage.py | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 amanuensis/user/manage.py diff --git a/amanuensis/user/__init__.py b/amanuensis/user/__init__.py index f3ba749..6d8a7c7 100644 --- a/amanuensis/user/__init__.py +++ b/amanuensis/user/__init__.py @@ -1,9 +1,11 @@ +from amanuensis.user.manage import load_all_users from amanuensis.user.signup import ( create_user, valid_username, valid_email) __all__ = [member.__name__ for member in [ + load_all_users, create_user, valid_username, valid_email, diff --git a/amanuensis/user/manage.py b/amanuensis/user/manage.py new file mode 100644 index 0000000..6440e97 --- /dev/null +++ b/amanuensis/user/manage.py @@ -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