Validate alias structure in prototype homogenization. Resolve #3578
This commit is contained in:
parent
1d689ed78c
commit
e80f513315
4 changed files with 16 additions and 10 deletions
|
|
@ -11,6 +11,8 @@ underline reset, italic/reset and strikethrough/reset (0xDEADFED5)
|
||||||
- [Feat][pull3582]: Add true-color parsing/fallback for ANSIString (0xDEADFED5)
|
- [Feat][pull3582]: Add true-color parsing/fallback for ANSIString (0xDEADFED5)
|
||||||
- [Fix][pull3571]: Better visual display of partial multimatch search results
|
- [Fix][pull3571]: Better visual display of partial multimatch search results
|
||||||
(InspectorCaracal)
|
(InspectorCaracal)
|
||||||
|
- [Fix][issue3378]: Prototype 'alias' key was not properly homogenized to a list
|
||||||
|
(Griatch)
|
||||||
- [Fix][pull3550]: Issue where rpsystem contrib search would do a global instead
|
- [Fix][pull3550]: Issue where rpsystem contrib search would do a global instead
|
||||||
of local search on multimatch (InspectorCaracal)
|
of local search on multimatch (InspectorCaracal)
|
||||||
- [Fix][pull3585]: `TagCmd.switch_options` was misnamed (erratic-pattern)
|
- [Fix][pull3585]: `TagCmd.switch_options` was misnamed (erratic-pattern)
|
||||||
|
|
@ -28,6 +30,7 @@ underline reset, italic/reset and strikethrough/reset (0xDEADFED5)
|
||||||
[pull3531]: https://github.com/evennia/evennia/pull/3531
|
[pull3531]: https://github.com/evennia/evennia/pull/3531
|
||||||
[pull3571]: https://github.com/evennia/evennia/pull/3571
|
[pull3571]: https://github.com/evennia/evennia/pull/3571
|
||||||
[pull3582]: https://github.com/evennia/evennia/pull/3582
|
[pull3582]: https://github.com/evennia/evennia/pull/3582
|
||||||
|
[issue3378]: https://github.com/evennia/evennia/issues/3578
|
||||||
|
|
||||||
## Evennia 4.2.0
|
## Evennia 4.2.0
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ from django.conf import settings
|
||||||
from django.core.paginator import Paginator
|
from django.core.paginator import Paginator
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
from django.utils.translation import gettext as _
|
from django.utils.translation import gettext as _
|
||||||
|
|
||||||
from evennia.locks.lockhandler import check_lockstring, validate_lockstring
|
from evennia.locks.lockhandler import check_lockstring, validate_lockstring
|
||||||
from evennia.objects.models import ObjectDB
|
from evennia.objects.models import ObjectDB
|
||||||
from evennia.scripts.scripts import DefaultScript
|
from evennia.scripts.scripts import DefaultScript
|
||||||
|
|
@ -104,6 +103,7 @@ def homogenize_prototype(prototype, custom_keys=None):
|
||||||
prototype[protkey] = ""
|
prototype[protkey] = ""
|
||||||
|
|
||||||
homogenized = {}
|
homogenized = {}
|
||||||
|
homogenized_aliases = []
|
||||||
homogenized_tags = []
|
homogenized_tags = []
|
||||||
homogenized_attrs = []
|
homogenized_attrs = []
|
||||||
homogenized_parents = []
|
homogenized_parents = []
|
||||||
|
|
@ -111,7 +111,10 @@ def homogenize_prototype(prototype, custom_keys=None):
|
||||||
for key, val in prototype.items():
|
for key, val in prototype.items():
|
||||||
if key in reserved:
|
if key in reserved:
|
||||||
# check all reserved keys
|
# check all reserved keys
|
||||||
if key == "tags":
|
if key == "aliases":
|
||||||
|
# make sure aliases are always in a list even if given as a single string
|
||||||
|
homogenized_aliases = make_iter(val)
|
||||||
|
elif key == "tags":
|
||||||
# tags must be on form [(tag, category, data), ...]
|
# tags must be on form [(tag, category, data), ...]
|
||||||
tags = make_iter(prototype.get("tags", []))
|
tags = make_iter(prototype.get("tags", []))
|
||||||
for tag in tags:
|
for tag in tags:
|
||||||
|
|
@ -160,13 +163,14 @@ def homogenize_prototype(prototype, custom_keys=None):
|
||||||
else:
|
else:
|
||||||
# normal prototype-parent names are added as-is
|
# normal prototype-parent names are added as-is
|
||||||
homogenized_parents.append(parent)
|
homogenized_parents.append(parent)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# another reserved key
|
# another reserved key
|
||||||
homogenized[key] = val
|
homogenized[key] = val
|
||||||
else:
|
else:
|
||||||
# unreserved keys -> attrs
|
# unreserved keys -> attrs
|
||||||
homogenized_attrs.append((key, val, None, ""))
|
homogenized_attrs.append((key, val, None, ""))
|
||||||
|
if homogenized_aliases:
|
||||||
|
homogenized["aliases"] = homogenized_aliases
|
||||||
if homogenized_attrs:
|
if homogenized_attrs:
|
||||||
homogenized["attrs"] = homogenized_attrs
|
homogenized["attrs"] = homogenized_attrs
|
||||||
if homogenized_tags:
|
if homogenized_tags:
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,6 @@ import re
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
from evennia.utils import logger, utils
|
from evennia.utils import logger, utils
|
||||||
from evennia.utils.hex_colors import HexColors
|
from evennia.utils.hex_colors import HexColors
|
||||||
from evennia.utils.utils import to_str
|
from evennia.utils.utils import to_str
|
||||||
|
|
@ -124,7 +123,7 @@ ANSI_TAB = "\t"
|
||||||
ANSI_SPACE = " "
|
ANSI_SPACE = " "
|
||||||
|
|
||||||
# Escapes
|
# Escapes
|
||||||
ANSI_ESCAPES = ("{{", "\\\\", "\|\|")
|
ANSI_ESCAPES = ("{{", r"\\", r"\|\|")
|
||||||
|
|
||||||
_PARSE_CACHE = OrderedDict()
|
_PARSE_CACHE = OrderedDict()
|
||||||
_PARSE_CACHE_SIZE = 10000
|
_PARSE_CACHE_SIZE = 10000
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,9 @@ class HexColors:
|
||||||
Based on code from @InspectorCaracal
|
Based on code from @InspectorCaracal
|
||||||
"""
|
"""
|
||||||
|
|
||||||
_RE_FG = "\|#"
|
_RE_FG = r"\|#"
|
||||||
_RE_BG = "\|\[#"
|
_RE_BG = r"\|\[#"
|
||||||
_RE_FG_OR_BG = "\|\[?#"
|
_RE_FG_OR_BG = r"\|\[?#"
|
||||||
_RE_HEX_LONG = "[0-9a-fA-F]{6}"
|
_RE_HEX_LONG = "[0-9a-fA-F]{6}"
|
||||||
_RE_HEX_SHORT = "[0-9a-fA-F]{3}"
|
_RE_HEX_SHORT = "[0-9a-fA-F]{3}"
|
||||||
_RE_BYTE = "[0-2]?[0-9]?[0-9]"
|
_RE_BYTE = "[0-2]?[0-9]?[0-9]"
|
||||||
|
|
@ -23,8 +23,8 @@ class HexColors:
|
||||||
# Used for greyscale
|
# Used for greyscale
|
||||||
_GREYS = "abcdefghijklmnopqrstuvwxyz"
|
_GREYS = "abcdefghijklmnopqrstuvwxyz"
|
||||||
|
|
||||||
TRUECOLOR_FG = f"\x1b\[38;2;{_RE_BYTE};{_RE_BYTE};{_RE_BYTE}m"
|
TRUECOLOR_FG = rf"\x1b\[38;2;{_RE_BYTE};{_RE_BYTE};{_RE_BYTE}m"
|
||||||
TRUECOLOR_BG = f"\x1b\[48;2;{_RE_BYTE};{_RE_BYTE};{_RE_BYTE}m"
|
TRUECOLOR_BG = rf"\x1b\[48;2;{_RE_BYTE};{_RE_BYTE};{_RE_BYTE}m"
|
||||||
|
|
||||||
# Our matchers for use with ANSIParser and ANSIString
|
# Our matchers for use with ANSIParser and ANSIString
|
||||||
hex_sub = re.compile(rf"{_RE_HEX_PATTERN}", re.DOTALL)
|
hex_sub = re.compile(rf"{_RE_HEX_PATTERN}", re.DOTALL)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue