From fb5dcc2eff1e5ff32684cc9fb1eec352b638d0aa Mon Sep 17 00:00:00 2001 From: Griatch Date: Sun, 14 Apr 2019 21:06:43 +0200 Subject: [PATCH] Remove validator container, allow direct setting of options --- evennia/__init__.py | 8 ++-- evennia/utils/containers.py | 10 ----- evennia/utils/optionclasses.py | 55 ++++++++++++++++-------- evennia/utils/optionhandler.py | 21 +++++++++ evennia/utils/validatorfuncs.py | 75 ++++++++++++++++++--------------- 5 files changed, 102 insertions(+), 67 deletions(-) diff --git a/evennia/__init__.py b/evennia/__init__.py index b903dafc2a..966002ae35 100644 --- a/evennia/__init__.py +++ b/evennia/__init__.py @@ -109,10 +109,9 @@ TASK_HANDLER = None TICKER_HANDLER = None MONITOR_HANDLER = None CHANNEL_HANDLER = None -GLOBAL_SCRIPTS = None # Containers -VALIDATOR_FUNCTIONS = None +GLOBAL_SCRIPTS = None OPTION_CLASSES = None @@ -161,8 +160,8 @@ def _init(): global create_message, create_help_entry global settings, lockfuncs, logger, utils, gametime, ansi, spawn, managers global contrib, TICKER_HANDLER, MONITOR_HANDLER, SESSION_HANDLER - global CHANNEL_HANDLER, TASK_HANDLER, GLOBAL_SCRIPTS - global VALIDATOR_FUNCS, OPTION_CLASSES + global CHANNEL_HANDLER, TASK_HANDLER + global GLOBAL_SCRIPTS, OPTION_CLASSES global EvMenu, EvTable, EvForm, EvMore, EvEditor global ANSIString @@ -226,7 +225,6 @@ def _init(): # containers from .utils.containers import GLOBAL_SCRIPTS - from .utils.containers import VALIDATOR_FUNCS from .utils.containers import OPTION_CLASSES # initialize the doc string diff --git a/evennia/utils/containers.py b/evennia/utils/containers.py index 1aa440d63b..5ee08d1604 100644 --- a/evennia/utils/containers.py +++ b/evennia/utils/containers.py @@ -76,15 +76,6 @@ class Container(object): return list(self.loaded_data.values()) -class ValidatorContainer(Container): - """ - Loads and stores the final list of VALIDATOR FUNCTIONS. - - Can access these as properties or dictionary-contents. - """ - storage_modules = settings.VALIDATOR_FUNC_MODULES - - class OptionContainer(Container): """ Loads and stores the final list of OPTION CLASSES. @@ -203,5 +194,4 @@ class GlobalScriptContainer(Container): # Create all singletons GLOBAL_SCRIPTS = GlobalScriptContainer() -VALIDATOR_FUNCS = ValidatorContainer() OPTION_CLASSES = OptionContainer() diff --git a/evennia/utils/optionclasses.py b/evennia/utils/optionclasses.py index 82b9c8619e..ded346c9cb 100644 --- a/evennia/utils/optionclasses.py +++ b/evennia/utils/optionclasses.py @@ -2,8 +2,8 @@ import datetime from evennia import logger from evennia.utils.ansi import strip_ansi from evennia.utils.validatorfuncs import _TZ_DICT -from evennia.utils.containers import VALIDATOR_FUNCS from evennia.utils.utils import crop +from evennia.utils import validatorfuncs class BaseOption(object): @@ -20,8 +20,6 @@ class BaseOption(object): validator_key (str): The key of the Validator this uses. """ - validator_key = '' - def __str__(self): return "