(cls, location, package_only=False)
| 521 | |
| 522 | @classmethod |
| 523 | def parse(cls, location, package_only=False): |
| 524 | |
| 525 | # The license files are in a directory which is the package name, |
| 526 | # for example: "/usr/share/licenses/openssl/LICENSE" |
| 527 | name = location.split('/usr/share/licenses/').pop().split('/')[0] |
| 528 | package_data = models.PackageData( |
| 529 | type=cls.default_package_type, |
| 530 | namespace=cls.default_package_namespace, |
| 531 | name=name, |
| 532 | datasource_id=cls.datasource_id, |
| 533 | ) |
| 534 | |
| 535 | if package_only: |
| 536 | yield package_data |
| 537 | |
| 538 | resource_license_attributes = get_licenses( |
| 539 | location=location, |
| 540 | include_text=True, |
| 541 | license_diagnostics=True, |
| 542 | license_text_diagnostics=True, |
| 543 | ) |
| 544 | for key, key_pkg in RESOURCE_TO_PACKAGE_LICENSE_FIELDS.items(): |
| 545 | setattr(package_data, key_pkg, resource_license_attributes.get(key)) |
| 546 | |
| 547 | yield package_data |
| 548 | |
| 549 | |
| 550 | ALGO_BY_ID = { |
nothing calls this directly
no test coverage detected