From ca98afb66dd83b7b4a9653eec1df5108e672787c Mon Sep 17 00:00:00 2001 From: Tim Van Baak Date: Thu, 30 Apr 2020 01:54:31 -0700 Subject: [PATCH] mypy pass --- amanuensis/lexicon/gameloop.py | 4 +- amanuensis/lexicon/manage.py | 158 ++++++++++++++++----------------- 2 files changed, 81 insertions(+), 81 deletions(-) diff --git a/amanuensis/lexicon/gameloop.py b/amanuensis/lexicon/gameloop.py index cbec9c9..089a1d5 100644 --- a/amanuensis/lexicon/gameloop.py +++ b/amanuensis/lexicon/gameloop.py @@ -126,10 +126,10 @@ def content_constraint_analysis( infos: list = [] warnings: list = [] errors: list = [] - character = lexicon.cfg.character.get(cid) + character = lexicon.cfg.character.get(cid)# noqa content_analysis: ConstraintAnalysis = ( parsed.render(ConstraintAnalysis(lexicon))) - with lexicon.ctx.read('info') as info: + with lexicon.ctx.read('info') as info:# noqa # I: Word count infos.append(f'Word count: {content_analysis.word_count}') # Self-citation when forbidden diff --git a/amanuensis/lexicon/manage.py b/amanuensis/lexicon/manage.py index b8673fa..bdfbeb0 100644 --- a/amanuensis/lexicon/manage.py +++ b/amanuensis/lexicon/manage.py @@ -1,99 +1,99 @@ -""" -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 +# """ +# 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, GetCitations, HtmlRenderer, filesafe_title, titlesort -from amanuensis.resources import get_stream +# 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, GetCitations, HtmlRenderer, filesafe_title, titlesort +# from amanuensis.resources import get_stream -def delete_lexicon(lex, purge=False): - """ - Deletes the given lexicon from the internal configuration +# 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)) +# 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 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 data folder if purging +# if purge: +# raise NotImplementedError() - # Delete the lexicon config - lex_path = prepend('lexicon', lex.id) - shutil.rmtree(lex_path) +# # 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 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)) +# 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) +# # 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 +# # 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)) +# 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] +# # 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] +# # Remove character from character list +# with json_rw(lex.config_path) as cfg: +# del cfg.character[char.cid]