feat: add glob method on ContentDirectory

This commit is contained in:
Corentin 2024-05-21 00:52:28 +02:00
parent f691669d76
commit 051a51280f
1 changed files with 5 additions and 1 deletions

View File

@ -1,6 +1,6 @@
from functools import cache from functools import cache
from pathlib import Path from pathlib import Path
from typing import Any, Iterator from typing import Any, Iterable, Iterator
from markdown import Markdown from markdown import Markdown
from yaml import Loader, load from yaml import Loader, load
@ -27,6 +27,10 @@ class ContentDirectory(Content):
return current return current
def glob(self, pattern: str) -> Iterable[Content]:
for item in self.path.glob(pattern):
yield self.load(str(item))
@cache # noqa: B019 @cache # noqa: B019
def __load_children(self, name: str) -> Content: def __load_children(self, name: str) -> Content:
child_path = self.path / name child_path = self.path / name