message: added rename_tags() function and test
This commit is contained in:
@@ -5,7 +5,7 @@ import pathlib
|
||||
import yaml
|
||||
from typing import Type, TypeVar, ClassVar, Optional, Any, Union, Final, Literal, Iterable
|
||||
from dataclasses import dataclass, asdict, field
|
||||
from .tags import Tag, TagLine, TagError, match_tags
|
||||
from .tags import Tag, TagLine, TagError, match_tags, rename_tags
|
||||
|
||||
QuestionInst = TypeVar('QuestionInst', bound='Question')
|
||||
AnswerInst = TypeVar('AnswerInst', bound='Answer')
|
||||
@@ -499,6 +499,14 @@ class Message():
|
||||
return False
|
||||
return True
|
||||
|
||||
def rename_tags(self, tags_rename: set[tuple[Tag, Tag]]) -> None:
|
||||
"""
|
||||
Renames the given tags. The first tuple element is the old name,
|
||||
the second one is the new name.
|
||||
"""
|
||||
if self.tags:
|
||||
self.tags = rename_tags(self.tags, tags_rename)
|
||||
|
||||
def msg_id(self) -> str:
|
||||
"""
|
||||
Returns an ID that is unique throughout all messages in the same (DB) directory.
|
||||
|
||||
Reference in New Issue
Block a user