From 640d56dba1cedb8125ff6881ee939a92168938d8 Mon Sep 17 00:00:00 2001 From: Griatch Date: Sun, 9 Jun 2019 18:03:53 +0200 Subject: [PATCH] Handle spawned attrs with dict, as per #1787 --- evennia/prototypes/menus.py | 2 +- evennia/prototypes/prototypes.py | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/evennia/prototypes/menus.py b/evennia/prototypes/menus.py index 61010b1004..5f38ab8f69 100644 --- a/evennia/prototypes/menus.py +++ b/evennia/prototypes/menus.py @@ -106,7 +106,7 @@ def _format_option_value(prop, required=False, prototype=None, cropper=None): if utils.is_iter(prop): out = ", ".join(str(pr) for pr in prop) if not out and required: - out = "|rreqrd" + out = "|runset" if out: return " ({}|n)".format(cropper(out) if cropper else utils.crop(out, _MENU_CROP_WIDTH)) return "" diff --git a/evennia/prototypes/prototypes.py b/evennia/prototypes/prototypes.py index 54d7ca84fb..2671382413 100644 --- a/evennia/prototypes/prototypes.py +++ b/evennia/prototypes/prototypes.py @@ -152,7 +152,7 @@ def save_prototype(prototype): Create/Store a prototype persistently. Args: - prototype (dict): The prototype to save. A `prototype_key` key is + prototype (dict): The prototype to save. A `prototype_key` key is required. Returns: @@ -267,18 +267,18 @@ def search_prototype(key=None, tags=None, require_single=False): Kwargs: key (str): An exact or partial key to query for. - tags (str or list): Tag key or keys to query for. These + tags (str or list): Tag key or keys to query for. These will always be applied with the 'db_protototype' tag category. require_single (bool): If set, raise KeyError if the result was not found or if there are multiple matches. Return: - matches (list): All found prototype dicts. Empty list if - no match was found. Note that if neither `key` nor `tags` + matches (list): All found prototype dicts. Empty list if + no match was found. Note that if neither `key` nor `tags` were given, *all* available prototypes will be returned. - Raises: + Raises: KeyError: If `require_single` is True and there are 0 or >1 matches. Note: @@ -336,7 +336,7 @@ def search_prototype(key=None, tags=None, require_single=False): if mta.get('prototype_key') and mta['prototype_key'] == key] if filter_matches and len(filter_matches) < nmatches: matches = filter_matches - + nmatches = len(matches) if nmatches != 1 and require_single: raise KeyError("Found {} matching prototypes.".format(nmatches)) @@ -739,7 +739,7 @@ def init_spawn_value(value, validator=None): validator = validator if validator else lambda o: o if callable(value): value = validator(value()) - elif value and is_iter(value) and callable(value[0]): + elif value and isinstance(value, (list, tuple)) and callable(value[0]): # a structure (callable, (args, )) args = value[1:] value = validator(value[0](*make_iter(args)))