游雁
2023-09-13 33d3d2084403fd34b79c835d2f2fe04f6cd8f738
funasr/fileio/datadir_writer.py
@@ -2,8 +2,6 @@
from typing import Union
import warnings
from typeguard import check_argument_types
from typeguard import check_return_type
class DatadirWriter:
@@ -20,7 +18,6 @@
    """
    def __init__(self, p: Union[Path, str]):
        assert check_argument_types()
        self.path = Path(p)
        self.chilidren = {}
        self.fd = None
@@ -31,7 +28,6 @@
        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")
@@ -41,11 +37,9 @@
            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:
@@ -57,6 +51,7 @@
        self.keys.add(key)
        self.fd.write(f"{key} {value}\n")
        self.fd.flush()
    def __exit__(self, exc_type, exc_val, exc_tb):
        self.close()