MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / set_purl

Method set_purl

src/packagedcode/models.py:302–316  ·  view source on GitHub ↗

Update this object with the ``package_url`` purl string or PackageURL if there is no pre-existing value for a given purl attribute.

(self, package_url)

Source from the content-addressed store, hash-verified

300 ).to_string()
301
302 def set_purl(self, package_url):
303 """
304 Update this object with the ``package_url`` purl string or PackageURL if
305 there is no pre-existing value for a given purl attribute.
306 """
307 if not package_url:
308 return
309
310 if not isinstance(package_url, PackageURL):
311 package_url = PackageURL.from_string(package_url)
312
313 for key, value in package_url.to_dict().items():
314 self_val = getattr(self, key)
315 if not self_val and value:
316 setattr(self, key, value)
317
318 def to_dict(self, **kwargs):
319 mapping = super().to_dict(**kwargs)

Callers 1

__attrs_post_init__Method · 0.80

Calls 1

to_dictMethod · 0.45

Tested by

no test coverage detected