Changeset View
Changeset View
Standalone View
Standalone View
swh/provenance/interface.py
# Copyright (C) 2021 The Software Heritage developers | # Copyright (C) 2021-2022 The Software Heritage developers | |||||||||||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | |||||||||||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | |||||||||||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | |||||||||||||
from __future__ import annotations | from __future__ import annotations | |||||||||||||
from dataclasses import dataclass | from dataclasses import dataclass | |||||||||||||
from datetime import datetime | from datetime import datetime | |||||||||||||
▲ Show 20 Lines • Show All 234 Lines • ▼ Show 20 Lines | class ProvenanceInterface(Protocol): | |||||||||||||
def close(self) -> None: | def close(self) -> None: | |||||||||||||
"""Close connection to the underlying `storage` and release resources.""" | """Close connection to the underlying `storage` and release resources.""" | |||||||||||||
... | ... | |||||||||||||
def flush(self) -> None: | def flush(self) -> None: | |||||||||||||
"""Flush internal cache to the underlying `storage`.""" | """Flush internal cache to the underlying `storage`.""" | |||||||||||||
... | ... | |||||||||||||
def flush_if_necessary(self) -> bool: | ||||||||||||||
"""Flush internal cache to the underlying `storage`, if the cache reached | ||||||||||||||
a threshold (MAX_CACHE_ELEMENTS). | ||||||||||||||
ardumontUnsubmitted Done Inline Actions
ardumont: | ||||||||||||||
Return True if the cache is flushed, false otherwise. | ||||||||||||||
""" | ||||||||||||||
... | ||||||||||||||
def content_add_to_directory( | def content_add_to_directory( | |||||||||||||
self, directory: DirectoryEntry, blob: FileEntry, prefix: bytes | self, directory: DirectoryEntry, blob: FileEntry, prefix: bytes | |||||||||||||
) -> None: | ) -> None: | |||||||||||||
"""Associate `blob` with `directory` in the provenance model. `prefix` is the | """Associate `blob` with `directory` in the provenance model. `prefix` is the | |||||||||||||
relative path from `directory` to `blob` (excluding `blob`'s name). | relative path from `directory` to `blob` (excluding `blob`'s name). | |||||||||||||
""" | """ | |||||||||||||
... | ... | |||||||||||||
▲ Show 20 Lines • Show All 129 Lines • Show Last 20 Lines |