| | |
| | | from typing import Union |
| | | import warnings |
| | | |
| | | from typeguard import check_argument_types |
| | | from typeguard import check_return_type |
| | | |
| | | |
| | | class DatadirWriter: |
| | |
| | | """ |
| | | |
| | | def __init__(self, p: Union[Path, str]): |
| | | assert check_argument_types() |
| | | self.path = Path(p) |
| | | self.chilidren = {} |
| | | self.fd = None |
| | |
| | | return self |
| | | |
| | | def __getitem__(self, key: str) -> "DatadirWriter": |
| | | assert check_argument_types() |
| | | if self.fd is not None: |
| | | raise RuntimeError("This writer points out a file") |
| | | |
| | |
| | | self.has_children = True |
| | | |
| | | retval = self.chilidren[key] |
| | | assert check_return_type(retval) |
| | | return retval |
| | | |
| | | def __setitem__(self, key: str, value: str): |
| | | assert check_argument_types() |
| | | if self.has_children: |
| | | raise RuntimeError("This writer points out a directory") |
| | | if key in self.keys: |