

def get(self, key, default=None, category=None, return_tagobj=False):
    '\n        Get the tag for the given key or list of tags.\n\n        Args:\n            key (str or list): The tag or tags to retrieve.\n            default (any, optional): The value to return in case of no match.\n            category (str, optional): The Tag category to limit the\n                request to. Note that `None` is the valid, default\n                category.\n            return_tagobj (bool, optional): Return the Tag object itself\n                instead of a string representation of the Tag.\n\n        Returns:\n            tags (str, TagObject or list): The matches, either string\n                representations of the tags or the Tag objects themselves\n                depending on `return_tagobj`.\n\n        '
    if ((self._cache is None) or (not _TYPECLASS_AGGRESSIVE_CACHE)):
        self._recache()
    ret = []
    category = (category.strip().lower() if (category is not None) else None)
    searchkey = [(('%s-%s' % (key.strip().lower(), category)) if (key is not None) else None) for key in make_iter(key)]
    ret = [val for val in (self._cache.get(keystr) for keystr in searchkey) if val]
    ret = ([to_str(tag.db_data) for tag in ret] if return_tagobj else ret)
    return (ret[0] if (len(ret) == 1) else (ret if ret else default))

dataset/ETHPy150Open evennia/evennia/evennia/typeclasses/tags.py TagHandler.get/original