Changeset View
Standalone View
swh/provenance/interface.py
Show First 20 Lines • Show All 294 Lines • ▼ Show 20 Lines | class ProvenanceInterface(Protocol): | ||||
def directory_add_to_revision( | def directory_add_to_revision( | ||||
self, revision: RevisionEntry, directory: DirectoryEntry, path: bytes | self, revision: RevisionEntry, directory: DirectoryEntry, path: bytes | ||||
) -> None: | ) -> None: | ||||
"""Associate `directory` with `revision` in the provenance model. `path` is the | """Associate `directory` with `revision` in the provenance model. `path` is the | ||||
absolute path from `revision`'s root directory to `directory` (including | absolute path from `revision`'s root directory to `directory` (including | ||||
`directory`'s name). | `directory`'s name). | ||||
""" | """ | ||||
... | ... | ||||
douardda: not very fond of the `True/False/None` API here, it's confusing. I think I'd prefer to raise a… | |||||
Done Inline ActionsI rather not use exceptions to represent a possible result. None here simply means that the directory is unknown to the provenance index. aeviso: I rather not use exceptions to represent a possible result. `None` here simply means that the… | |||||
Done Inline Actionsthe method is named directory_already_flattened, so it is expected to return True or False, and if the directory is not known, then False is the expected result: the directory is unknown from the provenance index thus, no, it's not flattened yet. This is related to the discussion about the Optional[bool] of the cache in D6712, right? douardda: the method is named `directory_already_flattened`, so it is expected to return True or False… | |||||
Done Inline ActionsNo, is the other way around actually. I needed a method to query whether the directory is already flattened or unknown, and then I picked a name. So, the method is not expected to return just True or False (see the documentation below). Regarding the discussion in D6712, that's related to having consistent information during the processing of a batch of elements. aeviso: No, is the other way around actually. I needed a method to query whether the directory is… | |||||
def directory_already_flattenned(self, directory: DirectoryEntry) -> Optional[bool]: | |||||
"""Check if the directory is already flattenned in the provenance model. If the | |||||
directory is unknown for the model, the methods returns None. | |||||
""" | |||||
... | |||||
def directory_flag_as_flattenned(self, directory: DirectoryEntry) -> None: | |||||
"""Mark the directory as flattenned in the provenance model. If the | |||||
directory is unknown for the model, this method has no effect. | |||||
""" | |||||
... | |||||
def directory_get_date_in_isochrone_frontier( | def directory_get_date_in_isochrone_frontier( | ||||
self, directory: DirectoryEntry | self, directory: DirectoryEntry | ||||
) -> Optional[datetime]: | ) -> Optional[datetime]: | ||||
"""Retrieve the earliest known date of `directory` as an isochrone frontier in | """Retrieve the earliest known date of `directory` as an isochrone frontier in | ||||
the provenance model. | the provenance model. | ||||
""" | """ | ||||
... | ... | ||||
▲ Show 20 Lines • Show All 73 Lines • Show Last 20 Lines |
not very fond of the True/False/None API here, it's confusing. I think I'd prefer to raise a NotFound kind-of exception. @olasd what do you think?