From 00b29a693df1c6f5df1b63ce049d48d78808ee3a Mon Sep 17 00:00:00 2001 From: Griatch Date: Wed, 3 Nov 2021 22:55:55 +0100 Subject: [PATCH] Change TagHandler.add/has(tag=...) kwarg to key= for consistency. Resolve #2396 --- CHANGELOG.md | 2 ++ evennia/typeclasses/tags.py | 18 +++++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f668974165..13909c5a12 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -112,6 +112,8 @@ Up requirements to Django 3.2+, Twisted 21+ to avoid known security issues with players entering MXP links. - Add browser name to webclient `CLIENT_NAME` in `session.protocol_flags`, e.g. `"Evennia webclient (websocket:firefox)"` or `"evennia webclient (ajax:chrome)"`. +- `TagHandler.add/has(tag=...)` kwarg changed to `add/has(key=...)` for consistency + with other handlers. ### Evennia 0.9.5 (2019-2020) diff --git a/evennia/typeclasses/tags.py b/evennia/typeclasses/tags.py index 56f42db4cd..1dffb0cfb8 100644 --- a/evennia/typeclasses/tags.py +++ b/evennia/typeclasses/tags.py @@ -290,12 +290,12 @@ class TagHandler(object): self._cache = {} self._catcache = {} - def add(self, tag=None, category=None, data=None): + def add(self, key=None, category=None, data=None): """ Add a new tag to the handler. Args: - tag (str or list): The name of the tag to add. If a list, + key (str or list): The name of the tag to add. If a list, add several Tags. category (str, optional): Category of Tag. `None` is the default category. data (str, optional): Info text about the tag(s) added. @@ -308,11 +308,11 @@ class TagHandler(object): will be created. """ - if not tag: + if not key: return if not self._cache_complete: self._fullcache() - for tagstr in make_iter(tag): + for tagstr in make_iter(key): if not tagstr: continue tagstr = str(tagstr).strip().lower() @@ -327,12 +327,12 @@ class TagHandler(object): getattr(self.obj, self._m2m_fieldname).add(tagobj) self._setcache(tagstr, category, tagobj) - def has(self, tag=None, category=None, return_list=False): + def has(self, key=None, category=None, return_list=False): """ Checks if the given Tag (or list of Tags) exists on the object. Args: - tag (str or iterable): The Tag key or tags to check for. + key (str or iterable): The Tag key or tags to check for. If `None`, search by category. category (str, optional): Limit the check to Tags with this category (note, that `None` is the default category). @@ -347,8 +347,8 @@ class TagHandler(object): """ ret = [] category = category.strip().lower() if category is not None else None - if tag: - for tag_str in make_iter(tag): + if key: + for tag_str in make_iter(key): tag_str = tag_str.strip().lower() ret.extend(bool(tag) for tag in self._getcache(tag_str, category)) elif category: @@ -515,7 +515,7 @@ class TagHandler(object): keys[tup[1]].append(tup[0]) data[tup[1]] = tup[2] # overwrite previous for category, key in keys.items(): - self.add(tag=key, category=category, data=data.get(category, None)) + self.add(key=key, category=category, data=data.get(category, None)) def __str__(self): return ",".join(self.all())