Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation_url to the Package Class #4099

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/packagedcode/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -1633,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.
Expand All @@ -1660,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)

Expand Down
Loading