Skip to content

Commit

Permalink
Fix the validity of SPDX outputs #180
Browse files Browse the repository at this point in the history
Signed-off-by: tdruez <tdruez@nexb.com>
  • Loading branch information
tdruez committed Oct 22, 2024
1 parent 47a4d14 commit 110b42d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ Release notes
- Fix the models documentation navigation.
https://github.com/aboutcode-org/dejacode/issues/182

- Fix the validity of SPDX outputs.
https://github.com/aboutcode-org/dejacode/issues/180

### Version 5.2.0

- Add visual indicator in hierarchy views, when an object on the far left or far right
Expand Down
12 changes: 10 additions & 2 deletions component_catalog/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1357,6 +1357,10 @@ def aboutcode_data(self):

return without_empty_values(component_data)

@property
def spdx_id(self):
return f"SPDXRef-dejacode-{self._meta.model_name}-{self.uuid}"

def as_spdx(self, license_concluded=None):
"""
Return this Component as an SPDX Package entry.
Expand All @@ -1375,7 +1379,7 @@ def as_spdx(self, license_concluded=None):

return spdx.Package(
name=self.name,
spdx_id=f"dejacode-{self._meta.model_name}-{self.uuid}",
spdx_id=self.spdx_id,
supplier=self.owner.as_spdx() if self.owner else "",
license_concluded=license_concluded or self.concluded_license_expression_spdx,
license_declared=self.declared_license_expression_spdx,
Expand Down Expand Up @@ -2248,6 +2252,10 @@ def get_about_files(self):

return about_files

@property
def spdx_id(self):
return f"SPDXRef-dejacode-{self._meta.model_name}-{self.uuid}"

def as_spdx(self, license_concluded=None):
"""
Return this Package as an SPDX Package entry.
Expand Down Expand Up @@ -2281,7 +2289,7 @@ def as_spdx(self, license_concluded=None):

return spdx.Package(
name=self.name or self.filename,
spdx_id=f"dejacode-{self._meta.model_name}-{self.uuid}",
spdx_id=self.spdx_id,
download_location=self.download_url,
license_concluded=license_concluded or self.concluded_license_expression_spdx,
license_declared=self.declared_license_expression_spdx,
Expand Down

0 comments on commit 110b42d

Please sign in to comment.