diff --git a/PKG-INFO b/PKG-INFO index d66225165474a4c06cbbffe272b2e664aab76e53..2b39d445071a74288e1f17dd61eb9983142f4d28 100644 --- a/PKG-INFO +++ b/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: swh.model -Version: 6.9.0 +Version: 6.9.1 Summary: Software Heritage data model Home-page: https://forge.softwareheritage.org/diffusion/DMOD/ Author: Software Heritage developers @@ -15,7 +15,7 @@ Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3) Classifier: Operating System :: OS Independent Classifier: Development Status :: 5 - Production/Stable Requires-Python: >=3.7 -Description-Content-Type: text/markdown +Description-Content-Type: text/x-rst License-File: LICENSE License-File: AUTHORS Requires-Dist: attrs!=21.1.0 @@ -49,16 +49,17 @@ Requires-Dist: swh.core>=0.3; extra == "testing" Requires-Dist: Click; extra == "testing" Requires-Dist: dulwich; extra == "testing" -swh-model -========= +Software Heritage - Data model +============================== Implementation of the Data model of the Software Heritage project, used to archive source code artifacts. -This module defines the notion of SoftWare Heritage persistent IDentifiers +This module defines the notion of SoftWare Hash persistent IDentifiers (SWHIDs) and provides tools to compute them: -```sh +.. code-block:: shell + $ swh-identify fork.c kmod.c sched/deadline.c swh:1:cnt:2e391c754ae730bd2d8520c2ab497c403220c6e3 fork.c swh:1:cnt:0277d1216f80ae1adeed84a686ed34c9b2931fc2 kmod.c @@ -66,4 +67,4 @@ This module defines the notion of SoftWare Heritage persistent IDentifiers $ swh-identify --no-filename /usr/src/linux/kernel/ swh:1:dir:f9f858a48d663b3809c9e2f336412717496202ab -``` + diff --git a/README.md b/README.rst similarity index 76% rename from README.md rename to README.rst index e6eae372ff27300ca05681a281f8c53c201182b5..6b88ad0aebd9de411aaf2fbc9a2b3306f4bdccf0 100644 --- a/README.md +++ b/README.rst @@ -1,13 +1,14 @@ -swh-model -========= +Software Heritage - Data model +============================== Implementation of the Data model of the Software Heritage project, used to archive source code artifacts. -This module defines the notion of SoftWare Heritage persistent IDentifiers +This module defines the notion of SoftWare Hash persistent IDentifiers (SWHIDs) and provides tools to compute them: -```sh +.. code-block:: shell + $ swh-identify fork.c kmod.c sched/deadline.c swh:1:cnt:2e391c754ae730bd2d8520c2ab497c403220c6e3 fork.c swh:1:cnt:0277d1216f80ae1adeed84a686ed34c9b2931fc2 kmod.c @@ -15,4 +16,4 @@ This module defines the notion of SoftWare Heritage persistent IDentifiers $ swh-identify --no-filename /usr/src/linux/kernel/ swh:1:dir:f9f858a48d663b3809c9e2f336412717496202ab -``` + diff --git a/docs/index.rst b/docs/index.rst index 23ef1e453ce71f491b6683663d7c1bc399b8e52b..d022ca1dcaf8d8e4485a610c9d33500afa9d7989 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,9 +1,6 @@ .. _swh-model: -Software Heritage - Data model -============================== - -Implementation of the :ref:`data-model` to archive source code artifacts. +.. include:: README.rst .. toctree:: :caption: Overview: diff --git a/setup.py b/setup.py index c0d8af253c761801ee733f2e37dd93fbc301e9f4..8698ecc1975a5ffe4091d738cb9407c2bc443bf5 100755 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ from setuptools import find_packages, setup here = path.abspath(path.dirname(__file__)) # Get the long description from the README file -with open(path.join(here, "README.md"), encoding="utf-8") as f: +with open(path.join(here, "README.rst"), encoding="utf-8") as f: long_description = f.read() @@ -39,7 +39,7 @@ setup( name="swh.model", description="Software Heritage data model", long_description=long_description, - long_description_content_type="text/markdown", + long_description_content_type="text/x-rst", python_requires=">=3.7", author="Software Heritage developers", author_email="swh-devel@inria.fr", diff --git a/swh.model.egg-info/PKG-INFO b/swh.model.egg-info/PKG-INFO index d66225165474a4c06cbbffe272b2e664aab76e53..2b39d445071a74288e1f17dd61eb9983142f4d28 100644 --- a/swh.model.egg-info/PKG-INFO +++ b/swh.model.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: swh.model -Version: 6.9.0 +Version: 6.9.1 Summary: Software Heritage data model Home-page: https://forge.softwareheritage.org/diffusion/DMOD/ Author: Software Heritage developers @@ -15,7 +15,7 @@ Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3) Classifier: Operating System :: OS Independent Classifier: Development Status :: 5 - Production/Stable Requires-Python: >=3.7 -Description-Content-Type: text/markdown +Description-Content-Type: text/x-rst License-File: LICENSE License-File: AUTHORS Requires-Dist: attrs!=21.1.0 @@ -49,16 +49,17 @@ Requires-Dist: swh.core>=0.3; extra == "testing" Requires-Dist: Click; extra == "testing" Requires-Dist: dulwich; extra == "testing" -swh-model -========= +Software Heritage - Data model +============================== Implementation of the Data model of the Software Heritage project, used to archive source code artifacts. -This module defines the notion of SoftWare Heritage persistent IDentifiers +This module defines the notion of SoftWare Hash persistent IDentifiers (SWHIDs) and provides tools to compute them: -```sh +.. code-block:: shell + $ swh-identify fork.c kmod.c sched/deadline.c swh:1:cnt:2e391c754ae730bd2d8520c2ab497c403220c6e3 fork.c swh:1:cnt:0277d1216f80ae1adeed84a686ed34c9b2931fc2 kmod.c @@ -66,4 +67,4 @@ This module defines the notion of SoftWare Heritage persistent IDentifiers $ swh-identify --no-filename /usr/src/linux/kernel/ swh:1:dir:f9f858a48d663b3809c9e2f336412717496202ab -``` + diff --git a/swh.model.egg-info/SOURCES.txt b/swh.model.egg-info/SOURCES.txt index d9a5a72ea13b62baaa53e63d667e6bdc9b866621..e835209099f5b62c794fd0f8ddde6eb5bd602c23 100644 --- a/swh.model.egg-info/SOURCES.txt +++ b/swh.model.egg-info/SOURCES.txt @@ -8,7 +8,7 @@ LICENSE MANIFEST.in Makefile Makefile.local -README.md +README.rst mypy.ini pyproject.toml pytest.ini diff --git a/swh/model/model.py b/swh/model/model.py index c919df0d7296afa7485b209b420992489f7f25e6..0170bcaf350579c995f3f39ea36fe7ad55dd9f56 100644 --- a/swh/model/model.py +++ b/swh/model/model.py @@ -382,7 +382,7 @@ def _compute_hash_from_manifest(manifest: bytes) -> Sha1Git: return hashlib.new("sha1", manifest).digest() -class HashableObject(metaclass=ABCMeta): +class BaseHashableModel(BaseModel, metaclass=ABCMeta): """Mixin to automatically compute object identifier hash when the associated model is instantiated.""" @@ -412,14 +412,17 @@ class HashableObject(metaclass=ABCMeta): return self.id def check(self) -> None: - super().check() # type: ignore + super().check() if self.id != self.compute_hash(): raise ValueError("'id' does not match recomputed hash.") -class HashableObjectWithManifest(HashableObject): - """Derived class of HashableObject, for objects that may need to store +HashableObject = BaseHashableModel # deprecated alias + + +class HashableObjectWithManifest(BaseHashableModel): + """Derived class of BaseHashableModel, for objects that may need to store verbatim git objects as ``raw_manifest`` to preserve original hashes.""" __slots__ = () @@ -767,7 +770,7 @@ class TimestampWithTimezone(BaseModel): @attr.s(frozen=True, slots=True, field_transformer=optimize_all_validators) -class Origin(HashableObject, BaseModel): +class Origin(BaseHashableModel): """Represents a software source: a VCS and an URL.""" object_type: Final = "origin" @@ -933,7 +936,7 @@ class SnapshotBranch(BaseModel): @attr.s(frozen=True, slots=True, field_transformer=optimize_all_validators) -class Snapshot(HashableObject, BaseModel): +class Snapshot(BaseHashableModel): """Represents the full state of an origin at a given point in time.""" object_type: Final = "snapshot" @@ -1651,7 +1654,7 @@ def normalize_discovery_date(value: Any) -> datetime.datetime: @attr.s(frozen=True, slots=True, field_transformer=optimize_all_validators) -class RawExtrinsicMetadata(HashableObject, BaseModel): +class RawExtrinsicMetadata(BaseHashableModel): object_type: Final = "raw_extrinsic_metadata" # target object @@ -1897,7 +1900,7 @@ class RawExtrinsicMetadata(HashableObject, BaseModel): @attr.s(frozen=True, slots=True, field_transformer=optimize_all_validators) -class ExtID(HashableObject, BaseModel): +class ExtID(BaseHashableModel): object_type: Final = "extid" extid_type = attr.ib(type=str, validator=generic_type_validator) diff --git a/swh/model/tests/test_model.py b/swh/model/tests/test_model.py index f2adc62941d98bff9752f10f151bbb1ba87c796d..248410f99fcbce422207294493b9993c11a2106e 100644 --- a/swh/model/tests/test_model.py +++ b/swh/model/tests/test_model.py @@ -1509,9 +1509,13 @@ def test_object_type(objtype_and_obj): def test_object_type_is_final(): + checked_classes = set() object_types = set() def check_final(cls): + if cls in checked_classes: + return + checked_classes.add(cls) if hasattr(cls, "object_type"): assert cls.object_type not in object_types object_types.add(cls.object_type)