diff --git a/amanuensis/lexicon/__init__.py b/amanuensis/lexicon/__init__.py
deleted file mode 100644
index b795fc9..0000000
--- a/amanuensis/lexicon/__init__.py
+++ /dev/null
@@ -1,32 +0,0 @@
-from .admin import (
- valid_name,
- create_lexicon,
- load_all_lexicons)
-from .gameloop import (
- get_player_characters,
- get_player_drafts,
- get_draft,
- title_constraint_analysis,
- content_constraint_analysis,
- sort_by_index_spec,
- attempt_publish)
-from .setup import (
- player_can_join_lexicon,
- add_player_to_lexicon,
- create_character_in_lexicon)
-
-__all__ = [member.__name__ for member in [
- valid_name,
- create_lexicon,
- load_all_lexicons,
- get_player_characters,
- get_player_drafts,
- get_draft,
- title_constraint_analysis,
- content_constraint_analysis,
- sort_by_index_spec,
- attempt_publish,
- player_can_join_lexicon,
- add_player_to_lexicon,
- create_character_in_lexicon,
-]]
diff --git a/amanuensis/lexicon/gameloop.py b/amanuensis/lexicon/gameloop.py
index e4d91db..6543c49 100644
--- a/amanuensis/lexicon/gameloop.py
+++ b/amanuensis/lexicon/gameloop.py
@@ -99,54 +99,6 @@ class HtmlRenderer(RenderableVisitor):
return f'{"".join(span.recurse(self))}'
-def get_player_characters(
- lexicon: LexiconModel,
- uid: str) -> Iterable[ReadOnlyOrderedDict]:
- """
- Returns each character in the lexicon owned by the given player
- """
- for character in lexicon.cfg.character.values():
- if character.player == uid:
- yield character
-
-
-def get_player_drafts(
- lexicon: LexiconModel,
- uid: str) -> Iterable[ReadOnlyOrderedDict]:
- """
- Returns each draft in the lexicon by a character owned by the
- given player.
- """
- characters = list(get_player_characters(lexicon, uid))
- drafts: List[Any] = []
- for filename in lexicon.ctx.draft.ls():
- for character in characters:
- if filename.startswith(character.cid):
- drafts.append(filename)
- break
- for i in range(len(drafts)):
- with lexicon.ctx.draft.read(drafts[i]) as draft:
- drafts[i] = draft
- return drafts
-
-
-def get_draft(
- lexicon: LexiconModel,
- aid: str) -> Optional[ReadOnlyOrderedDict]:
- """
- Loads an article from its id
- """
- article_fn = None
- for filename in lexicon.ctx.draft.ls():
- if filename.endswith(f'{aid}.json'):
- article_fn = filename
- break
- if not article_fn:
- return None
- with lexicon.ctx.draft.read(article_fn) as article:
- return article
-
-
def title_constraint_analysis(
lexicon: LexiconModel,
player: UserModel,
diff --git a/amanuensis/lexicon/manage.py b/amanuensis/lexicon/manage.py
deleted file mode 100644
index eb7844b..0000000
--- a/amanuensis/lexicon/manage.py
+++ /dev/null
@@ -1,99 +0,0 @@
-# """
-# Functions for managing lexicons, primarily within the context of the
-# Amanuensis config directory.
-# """
-# import json
-# import os
-# import re
-# import shutil
-# import time
-# import uuid
-
-# from amanuensis.config import prepend, json_rw, json_ro, logger
-# from amanuensis.config.loader import AttrOrderedDict
-# from amanuensis.errors import ArgumentError
-# from amanuensis.lexicon import LexiconModel
-# from amanuensis.parser import parse_raw_markdown, filesafe_title, titlesort
-# from amanuensis.resources import get_stream
-
-
-
-
-
-# def delete_lexicon(lex, purge=False):
-# """
-# Deletes the given lexicon from the internal configuration
-
-# Does not delete the lexicon from the data folder unless purge=True.
-# """
-# # Verify arguments
-# if lex is None:
-# raise ArgumentError("Invalid lexicon: '{}'".format(lex))
-
-# # Delete the lexicon from the index
-# with json_rw('lexicon', 'index.json') as index:
-# if lex.name in index:
-# del index[lex.name]
-
-# # Delete the lexicon data folder if purging
-# if purge:
-# raise NotImplementedError()
-
-# # Delete the lexicon config
-# lex_path = prepend('lexicon', lex.id)
-# shutil.rmtree(lex_path)
-
-
-# def get_user_lexicons(user):
-# """
-# Loads each lexicon that the given user is a player in
-# """
-# return [
-# lexicon
-# for lexicon in get_all_lexicons()
-# if user.in_lexicon(lexicon)]
-
-
-# def remove_player(lex, player):
-# """
-# Remove a player from a lexicon
-# """
-# # Verify arguments
-# if lex is None:
-# raise ArgumentError("Invalid lexicon: '{}'".format(lex))
-# if player is None:
-# raise ArgumentError("Invalid player: '{}'".format(player))
-# if lex.editor == player.id:
-# raise ArgumentError(
-# "Can't remove the editor '{}' from lexicon '{}'".format(
-# player.username, lex.name))
-
-# # Idempotently remove player
-# with json_rw(lex.config_path) as cfg:
-# if player.id in cfg.join.joined:
-# cfg.join.joined.remove(player.id)
-
-# # TODO Reassign the player's characters to the editor
-
-
-# def delete_character(lex, charname):
-# """
-# Delete a character from a lexicon
-# """
-# # Verify arguments
-# if lex is None:
-# raise ArgumentError("Invalid lexicon: '{}'".format(lex))
-# if charname is None:
-# raise ArgumentError("Invalid character name: '{}'".format(charname))
-
-# # Find character in this lexicon
-# matches = [
-# char for cid, char in lex.character.items()
-# if char.name == charname]
-# if len(matches) != 1:
-# raise ArgumentError(matches)
-# char = matches[0]
-
-# # Remove character from character list
-# with json_rw(lex.config_path) as cfg:
-# del cfg.character[char.cid]
diff --git a/amanuensis/lexicon/setup.py b/amanuensis/lexicon/setup.py
deleted file mode 100644
index e9d59c5..0000000
--- a/amanuensis/lexicon/setup.py
+++ /dev/null
@@ -1,81 +0,0 @@
-"""
-Submodule of functions for managing lexicon games during the setup and
-joining part of the game lifecycle.
-"""
-import json
-import uuid
-
-from amanuensis.config import AttrOrderedDict
-from amanuensis.errors import ArgumentError
-from amanuensis.models import LexiconModel, UserModel
-from amanuensis.resources import get_stream
-
-
-def player_can_create_character(
- player: UserModel,
- lexicon: LexiconModel,
- name: str) -> bool:
- """
- Checks whether a player can create a character with the given name
- """
- # Trivial failures
- if not player or not lexicon or not name:
- return False
- # User needs to be a player
- if player.uid not in lexicon.cfg.join.joined:
- return False
- # Character can't be a dupe
- if any([
- char.name for char in lexicon.cfg.character.values()
- if char.name == name]):
- return False
- # Player can't add more characters than the limit
- if len([
- char for char in lexicon.cfg.character.values()
- if char.player == player.uid]) > lexicon.cfg.join.chars_per_player:
- return False
- # Players can't add characters after the game has started
- if lexicon.cfg.turn.current:
- return False
- return True
-
-
-def create_character_in_lexicon(
- player: UserModel,
- lexicon: LexiconModel,
- name: str) -> str:
- """
- Unconditionally creates a character for a player
- """
- # Verify arguments
- if lexicon is None:
- raise ArgumentError(f'Invalid lexicon: {lexicon}')
- if player is None:
- raise ArgumentError(f'Invalid player: {player}')
- if player.uid not in lexicon.cfg.join.joined:
- raise ArgumentError(f'Player {player} not in lexicon {lexicon}')
- if not name:
- raise ArgumentError(f'Invalid character name: "{name}"')
- if any([
- char.name for char in lexicon.cfg.character.values()
- if char.name == name]):
- raise ArgumentError(f'Duplicate character name: "{name}"')
-
- # Load the character template
- with get_stream('character.json') as template:
- character = json.load(template, object_pairs_hook=AttrOrderedDict)
-
- # Fill out the character's information
- character.cid = uuid.uuid4().hex
- character.name = name
- character.player = player.uid
- character.signature = "~" + character.name
-
- # Add the character to the lexicon
- with lexicon.ctx.edit_config() as cfg:
- cfg.character.new(character.cid, character)
-
- # Log addition
- lexicon.log(f'Character "{name}" created ({character.cid})')
-
- return character.cid
diff --git a/amanuensis/server/forms.py b/amanuensis/server/forms.py
deleted file mode 100644
index 26ef5a3..0000000
--- a/amanuensis/server/forms.py
+++ /dev/null
@@ -1,33 +0,0 @@
-from flask import current_app
-from wtforms.validators import ValidationError
-
-from amanuensis.config import RootConfigDirectoryContext
-
-
-# Custom validators
-def User(should_exist: bool = True):
- template: str = 'User "{{}}" {}'.format(
- "not found" if should_exist else "already exists")
- should_exist_copy: bool = bool(should_exist)
-
- def validate_user(form, field):
- root: RootConfigDirectoryContext = current_app.config['root']
- with root.user.read_index() as index:
- if (field.data in index.keys()) != should_exist_copy:
- raise ValidationError(template.format(field.data))
-
- return validate_user
-
-
-def Lexicon(should_exist: bool = True):
- template: str = 'Lexicon "{{}}" {}'.format(
- "not found" if should_exist else "already exists")
- should_exist_copy: bool = bool(should_exist)
-
- def validate_lexicon(form, field):
- root: RootConfigDirectoryContext = current_app.config['root']
- with root.lexicon.read_index() as index:
- if (field.data in index.keys()) != should_exist_copy:
- raise ValidationError(template.format(field.data))
-
- return validate_lexicon
diff --git a/amanuensis/server/session/forms.py b/amanuensis/server/session/forms.py
index ce711a2..2e738cc 100644
--- a/amanuensis/server/session/forms.py
+++ b/amanuensis/server/session/forms.py
@@ -6,25 +6,6 @@ from wtforms.validators import DataRequired
from .settings import ConfigFormBase
-class LexiconCharacterForm(FlaskForm):
- """/lexicon//session/character/"""
- characterName = StringField(
- 'Character name',
- validators=[DataRequired()])
- defaultSignature = TextAreaField('Default signature')
- submit = SubmitField('Submit')
-
- def for_new(self):
- self.characterName.data = ""
- self.defaultSignature.data = "~"
- return self
-
- def for_character(self, character):
- self.characterName.data = character.name
- self.defaultSignature.data = character.signature
- return self
-
-
class LexiconReviewForm(FlaskForm):
"""/lexicon//session/review/"""
APPROVED = 'Y'