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

Function get_base_purl

src/packagedcode/utils.py:286–298  ·  view source on GitHub ↗

Get a base purl with only the type, name and namespace from a given purl.

(purl)

Source from the content-addressed store, hash-verified

284
285
286def get_base_purl(purl):
287 """
288 Get a base purl with only the type, name and namespace from
289 a given purl.
290 """
291 base_purl_fields = ["type", "namespace", "name"]
292 purl_mapping = PackageURL.from_string(purl=purl).to_dict()
293 base_purl_mapping = {
294 purl_field: purl_value
295 for purl_field, purl_value in purl_mapping.items()
296 if purl_field in base_purl_fields
297 }
298 return PackageURL(**base_purl_mapping).to_string()
299
300
301def is_simple_path(path):

Calls 2

to_stringMethod · 0.80
to_dictMethod · 0.45

Tested by

no test coverage detected