Compare commits
8 Commits
e7e3e26712
...
dc864da8c0
| Author | SHA1 | Date | |
|---|---|---|---|
| dc864da8c0 | |||
| 1325789f18 | |||
| 1a14c0e4a8 | |||
| 2b1d4f248b | |||
| 7e3cd13304 | |||
| ec0371c492 | |||
| ce90ba2cbb | |||
| d089300862 |
@ -242,25 +242,6 @@ class Message():
|
|||||||
tags = set(sorted(data[cls.tags_yaml_key]))
|
tags = set(sorted(data[cls.tags_yaml_key]))
|
||||||
return tags
|
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
|
@classmethod
|
||||||
def from_file(cls: Type[MessageInst], file_path: pathlib.Path,
|
def from_file(cls: Type[MessageInst], file_path: pathlib.Path,
|
||||||
mfilter: Optional[MessageFilter] = None) -> Optional[MessageInst]:
|
mfilter: Optional[MessageFilter] = None) -> Optional[MessageInst]:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user