From 0e9d10037735f752489f2373dadadda11acdacdc Mon Sep 17 00:00:00 2001 From: Asim kumar Date: Wed, 15 Jan 2025 08:08:45 +0000 Subject: [PATCH 1/2] feat(models): add documentation_url field to Package class Signed-off-by: Asim kumar --- src/packagedcode/models.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/packagedcode/models.py b/src/packagedcode/models.py index d518c73330..7ee56758aa 100644 --- a/src/packagedcode/models.py +++ b/src/packagedcode/models.py @@ -1619,6 +1619,12 @@ class Package(PackageData): help='List of the datasource ids used to create this package.' ) + documentation_url = String( + label='Documentation URL', + help='URL that documents this package.' + + ) + def __attrs_post_init__(self, *args, **kwargs): if not self.purl: self.purl = self.set_purl() From 24e18d3b117522c002c53706b9120c5d1e516855 Mon Sep 17 00:00:00 2001 From: Asim kumar Date: Wed, 15 Jan 2025 19:23:35 +0000 Subject: [PATCH 2/2] added documentation_url to the Package class Signed-off-by: Asim kumar --- src/packagedcode/models.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/packagedcode/models.py b/src/packagedcode/models.py index 7ee56758aa..9af17eaacc 100644 --- a/src/packagedcode/models.py +++ b/src/packagedcode/models.py @@ -1639,10 +1639,11 @@ def to_package_data(self): mapping.pop('package_uid', None) mapping.pop('datafile_paths', None) mapping.pop('datasource_ids', None) + mapping.pop('documentation_url', None) return PackageData.from_dict(mapping) @classmethod - def from_package_data(cls, package_data, datafile_path=None, package_only=False): + def from_package_data(cls, package_data, datafile_path=None, package_only=False , documentation_url=None): """ Return a Package from a ``package_data`` PackageData object or mapping. Or None. @@ -1666,6 +1667,8 @@ def from_package_data(cls, package_data, datafile_path=None, package_only=False) for license_match in detection['matches']: if not license_match['from_file']: license_match['from_file'] = datafile_path + if documentation_url: + package_data_mapping['documentation_url'] = documentation_url package = cls.from_dict(package_data_mapping)