From 3c62acc975835da9c9c90687d869426dcc0a770c Mon Sep 17 00:00:00 2001 From: Tim Van Baak Date: Sun, 19 Jan 2020 07:43:41 -0800 Subject: [PATCH] Implement lexicon-player-list --- amanuensis/cli/lexicon.py | 20 +++++++++++++++++++- amanuensis/lexicon/manage.py | 8 +------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/amanuensis/cli/lexicon.py b/amanuensis/cli/lexicon.py index 74becbb..3db0fb4 100644 --- a/amanuensis/cli/lexicon.py +++ b/amanuensis/cli/lexicon.py @@ -179,7 +179,25 @@ def command_player_list(args): """ List all players in a lexicon """ - raise NotImplementedError() # TODO + import json + # Module imports + from lexicon import LexiconModel + from user import UserModel + + # Verify arguments + lex = LexiconModel.by(name=args.lexicon) + if lex is None: + logger.error("Could not find lexicon '{}'".format(args.lexicon)) + return -1 + + # Internal call + players = [] + for uid in lex.join.joined: + u = UserModel.by(uid=uid) + players.append(u.username) + + print(json.dumps(players, indent=2)) + @requires_lexicon @requires_username diff --git a/amanuensis/lexicon/manage.py b/amanuensis/lexicon/manage.py index 7fe0763..00c9ad8 100644 --- a/amanuensis/lexicon/manage.py +++ b/amanuensis/lexicon/manage.py @@ -155,10 +155,4 @@ def remove_player(lex, player): if player.id in cfg.join.joined: cfg.join.joined.remove(player.id) - # TODO Reassign the player's characters to the editor - - -def list_players(lex): - """ - """ - pass \ No newline at end of file + # TODO Reassign the player's characters to the editor \ No newline at end of file