diff options
| author | J08nY | 2025-02-17 12:08:03 +0100 |
|---|---|---|
| committer | J08nY | 2025-02-17 12:08:03 +0100 |
| commit | 67ccbf3f4792fe39f9c75e0546140930d6dccd40 (patch) | |
| tree | bc5968022987518093bdf8377d8c1843666839f7 /src/sec_certs/dataset | |
| parent | c06dc527b4f80bff4266a245482f9bf98eb38a28 (diff) | |
| download | sec-certs-67ccbf3f4792fe39f9c75e0546140930d6dccd40.tar.gz sec-certs-67ccbf3f4792fe39f9c75e0546140930d6dccd40.tar.zst sec-certs-67ccbf3f4792fe39f9c75e0546140930d6dccd40.zip | |
Document the backed status of datasets.
Diffstat (limited to 'src/sec_certs/dataset')
| -rw-r--r-- | src/sec_certs/dataset/auxiliary_dataset_handling.py | 7 | ||||
| -rw-r--r-- | src/sec_certs/dataset/dataset.py | 14 | ||||
| -rw-r--r-- | src/sec_certs/dataset/json_path_dataset.py | 7 |
3 files changed, 21 insertions, 7 deletions
diff --git a/src/sec_certs/dataset/auxiliary_dataset_handling.py b/src/sec_certs/dataset/auxiliary_dataset_handling.py index dc6993df..cd67f929 100644 --- a/src/sec_certs/dataset/auxiliary_dataset_handling.py +++ b/src/sec_certs/dataset/auxiliary_dataset_handling.py @@ -33,6 +33,13 @@ class AuxiliaryDatasetHandler(ABC): self.aux_datasets_dir = Path(aux_datasets_dir) if aux_datasets_dir is not None else None # type: ignore @property + def is_backed(self) -> bool: + """ + Returns whether the dataset is backed by a directory. + """ + return self.aux_datasets_dir is not None + + @property def root_dir(self) -> Path: if self.RELATIVE_DIR: return self.aux_datasets_dir / Path(self.RELATIVE_DIR) diff --git a/src/sec_certs/dataset/dataset.py b/src/sec_certs/dataset/dataset.py index 70bf3830..7add7b52 100644 --- a/src/sec_certs/dataset/dataset.py +++ b/src/sec_certs/dataset/dataset.py @@ -71,6 +71,13 @@ class Dataset(Generic[CertSubType], ComplexSerializableType, ABC): self._set_local_paths() @property + def is_backed(self) -> bool: + """ + Returns whether the dataset is backed by a directory. + """ + return self.root_dir is not None + + @property def root_dir(self) -> Path: """ Directory that will hold the serialized dataset files. @@ -95,13 +102,6 @@ class Dataset(Generic[CertSubType], ComplexSerializableType, ABC): self._set_local_paths() @property - def is_backed(self) -> bool: - """ - Returns whether the dataset is backed by a directory. - """ - return self.root_dir is not None - - @property @only_backed(throw=False) def web_dir(self) -> Path: """ diff --git a/src/sec_certs/dataset/json_path_dataset.py b/src/sec_certs/dataset/json_path_dataset.py index 8b9212b7..76df73f2 100644 --- a/src/sec_certs/dataset/json_path_dataset.py +++ b/src/sec_certs/dataset/json_path_dataset.py @@ -18,6 +18,13 @@ class JSONPathDataset(ComplexSerializableType, ABC): self.json_path = Path(json_path) if json_path is not None else None @property + def is_backed(self) -> bool: + """ + Returns whether the dataset is backed by a JSON file. + """ + return self.json_path is not None + + @property def json_path(self) -> Path | None: return self._json_path |
