From e9142a7f56cbd5db5b7ef51e1c2ceedbd97ac4ba Mon Sep 17 00:00:00 2001 From: Tim Van Baak Date: Wed, 29 Jan 2020 08:22:51 -0800 Subject: [PATCH] Update user-list --- amanuensis/cli/user.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/amanuensis/cli/user.py b/amanuensis/cli/user.py index ae3054e..acce9b6 100644 --- a/amanuensis/cli/user.py +++ b/amanuensis/cli/user.py @@ -72,21 +72,18 @@ def command_list(args): """List all users""" # Module imports from amanuensis.config import prepend, json_ro + from amanuensis.user import UserModel # Perform command - user_dirs = os.listdir(prepend('user')) users = [] - for uid in user_dirs: - if uid == "index.json": - continue - with json_ro('user', uid, 'config.json') as user: - users.append(user) - + with json_ro('user', 'index.json') as index: + for username, uid in index.items(): + users.append(UserModel.by(uid=uid)) + # Output - users.sort(key=lambda u: u['username']) + users.sort(key=lambda u: u.username) for user in users: - print("{0} {1} ({2})".format( - user['uid'], user['displayname'], user['username'])) + print("{0.id} {0.displayname} ({0.username})".format(user)) return 0 @@ -136,7 +133,7 @@ def command_passwd(args): # Verify arguments pw = args.password or getpass.getpass("Password: ") - # Perform commands + # Perform command args.user.set_password(pw) # Output