Identifiable package data object using purl as identifying attribute as specified here https://github.com/package-url/purl-spec. This base class is used for all package-like objects be they a manifest or an actual package instance.
| 243 | |
| 244 | @attr.attributes(slots=True) |
| 245 | class IdentifiablePackageData(ModelMixin): |
| 246 | """ |
| 247 | Identifiable package data object using purl as identifying attribute as |
| 248 | specified here https://github.com/package-url/purl-spec. |
| 249 | This base class is used for all package-like objects be they a manifest |
| 250 | or an actual package instance. |
| 251 | """ |
| 252 | type = String( |
| 253 | repr=True, |
| 254 | label='package type', |
| 255 | help='A short code to identify what is the type of this ' |
| 256 | 'package. For instance gem for a Rubygem, docker for container, ' |
| 257 | 'pypi for Python Wheel or Egg, maven for a Maven Jar, ' |
| 258 | 'deb for a Debian package, etc.') |
| 259 | |
| 260 | namespace = String( |
| 261 | repr=True, |
| 262 | label='package namespace', |
| 263 | help='Namespace for this package.') |
| 264 | |
| 265 | name = String( |
| 266 | repr=True, |
| 267 | label='package name', |
| 268 | help='Name of the package.') |
| 269 | |
| 270 | version = String( |
| 271 | repr=True, |
| 272 | label='package version', |
| 273 | help='Version of the package as a string.') |
| 274 | |
| 275 | qualifiers = Mapping( |
| 276 | default=None, |
| 277 | value_type=str, |
| 278 | converter=lambda v: normalize_qualifiers(v, encode=False), |
| 279 | label='package qualifiers', |
| 280 | help='Mapping of key=value pairs qualifiers for this package') |
| 281 | |
| 282 | subpath = String( |
| 283 | label='extra package subpath', |
| 284 | help='Subpath inside a package and relative to the root ' |
| 285 | 'of this package') |
| 286 | |
| 287 | @property |
| 288 | def purl(self): |
| 289 | """ |
| 290 | Return a compact Package URL string or None. |
| 291 | """ |
| 292 | if self.name: |
| 293 | return PackageURL( |
| 294 | type=self.type, |
| 295 | namespace=self.namespace, |
| 296 | name=self.name, |
| 297 | version=self.version, |
| 298 | qualifiers=self.qualifiers, |
| 299 | subpath=self.subpath, |
| 300 | ).to_string() |
| 301 | |
| 302 | def set_purl(self, package_url): |