refactor: do not make ContentField inherit from Content
This commit is contained in:
parent
35454bfc0f
commit
77c30117ed
|
|
@ -26,13 +26,17 @@ class Content(Generic[TData]):
|
|||
return str(self.__data)
|
||||
|
||||
|
||||
class ContentField(Content[Any]):
|
||||
class ContentField:
|
||||
def __init__(self, content_path: Path, value: Any) -> None:
|
||||
self.__content_path = content_path
|
||||
self.__value = value
|
||||
|
||||
def __getitem__(self, key: Any) -> Any:
|
||||
return ContentField(self.path, self.data.get(key), self.language)
|
||||
return ContentField(self.__content_path, self.__value.get(key))
|
||||
|
||||
def __iter__(self) -> Iterator[Any]:
|
||||
for it in self.data:
|
||||
yield ContentField(self.path, it, self.language)
|
||||
for it in self.__value:
|
||||
yield ContentField(self.__content_path, it)
|
||||
|
||||
def __str__(self) -> str:
|
||||
return str(self.data)
|
||||
return str(self.__value)
|
||||
|
|
|
|||
|
|
@ -27,4 +27,4 @@ class _MarkdownDocument(Content[str]):
|
|||
|
||||
@property
|
||||
def meta(self) -> Any:
|
||||
return ContentField(self.__content.path, self.__markdown.Meta, self.__content.language) # type: ignore
|
||||
return ContentField(self.__content.path, self.__markdown.Meta) # type: ignore
|
||||
|
|
|
|||
|
|
@ -20,4 +20,4 @@ def _load_yaml(content: Any) -> ContentField:
|
|||
|
||||
assert isinstance(data, str)
|
||||
|
||||
return ContentField(content.path, load(data, Loader), content.language)
|
||||
return ContentField(content.path, load(data, Loader))
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: PROJECT VERSION\n"
|
||||
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
|
||||
"POT-Creation-Date: 2024-05-21 23:42+0200\n"
|
||||
"POT-Creation-Date: 2024-05-21 23:52+0200\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language: fr\n"
|
||||
|
|
|
|||
Loading…
Reference in New Issue