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

Function build_purl

src/packagedcode/models.py:1578–1599  ·  view source on GitHub ↗

Return a PackageURL from a ``mapping`` or None if essential type and name fields are missing.

(mapping)

Source from the content-addressed store, hash-verified

1576
1577
1578def build_purl(mapping):
1579 """
1580 Return a PackageURL from a ``mapping`` or None if essential type and name
1581 fields are missing.
1582 """
1583 ptype = mapping.get('type')
1584 name = mapping.get('name')
1585 if not ptype or not name:
1586 return
1587
1588 namespace = mapping.get('namespace')
1589 version = mapping.get('version')
1590 qualifiers = mapping.get('qualifiers') or {}
1591 subpath = mapping.get('subpath')
1592 return PackageURL(
1593 type=ptype,
1594 namespace=namespace,
1595 name=name,
1596 version=version,
1597 qualifiers=qualifiers,
1598 subpath=subpath,
1599 )
1600
1601
1602@attr.attributes(slots=True)

Callers 1

from_dictMethod · 0.85

Calls 1

getMethod · 0.65

Tested by

no test coverage detected