Compare commits
8 Commits
dc864da8c0
...
e7e3e26712
| Author | SHA1 | Date | |
|---|---|---|---|
| e7e3e26712 | |||
| 71f6613aca | |||
| 9aafdf9421 | |||
| 56dda78d53 | |||
| c1d1027c60 | |||
| 5f8301cd2b | |||
| 87c05b5ff3 | |||
| 3238817eb2 |
@ -242,6 +242,25 @@ class Message():
|
||||
tags = set(sorted(data[cls.tags_yaml_key]))
|
||||
return tags
|
||||
|
||||
@classmethod
|
||||
def tags_from_dir(cls: Type[MessageInst],
|
||||
path: pathlib.Path,
|
||||
glob: Optional[str] = None,
|
||||
prefix: Optional[str] = None) -> set[Tag]:
|
||||
"""
|
||||
Return only the tags from message files in the given directory.
|
||||
The files can be filtered using 'glob', the tags by using 'prefix'.
|
||||
"""
|
||||
tags: set[Tag] = set()
|
||||
file_iter = path.glob(glob) if glob else path.iterdir()
|
||||
for file_path in sorted(file_iter):
|
||||
if file_path.is_file():
|
||||
try:
|
||||
tags |= cls.tags_from_file(file_path, prefix)
|
||||
except MessageError as e:
|
||||
print(f"Error processing message in '{file_path}': {str(e)}")
|
||||
return tags
|
||||
|
||||
@classmethod
|
||||
def from_file(cls: Type[MessageInst], file_path: pathlib.Path,
|
||||
mfilter: Optional[MessageFilter] = None) -> Optional[MessageInst]:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user