feat: add accessor and iterator method on data field

This commit is contained in:
Corentin 2024-05-20 21:43:19 +02:00
parent 562ecf366c
commit f691669d76
1 changed files with 7 additions and 0 deletions

View File

@ -56,6 +56,13 @@ class DataField:
def __str__(self) -> str:
return str(self.__value)
def __getitem__(self, key: Any) -> Any:
return DataField(self.__file, self.__value.get(key))
def __iter__(self) -> Iterator[Any]:
for it in self.__value:
yield DataField(self.__file, it)
class DataFile(Content):
def __init__(self, path: Path) -> None: