

def add(self, tag=None, category=None, data=None):
    '\n        Add a new tag to the handler.\n\n        Args:\n            tag (str or list): The name of the tag to add. If a list,\n                add several Tags.\n            category (str, optional): Category of Tag. `None` is the default category.\n            data (str, optional): Info text about the tag(s) added.\n                This can not be used to store object-unique info but only\n                eventual info about the text itself.\n\n        Notes:\n            If the tag + category combination matches an already\n            existing Tag object, this will be re-used and no new Tag\n            will be created.\n\n        '
    if (not tag):
        return
    for tagstr in make_iter(tag):
        if (not tagstr):
            continue
        tagstr = tagstr.strip().lower()
        category = (category.strip().lower() if (category is not None) else None)
        data = (str(data) if (data is not None) else None)
        tagobj = self.obj.__class__.objects.create_tag(key=tagstr, category=category, data=data, tagtype=self._tagtype)
        getattr(self.obj, self._m2m_fieldname).add(tagobj)
        if (self._cache is None):
            self._recache()
        cachestring = ('%s-%s' % (tagstr, category))
        self._cache[cachestring] = tagobj

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