(cls, package_data, resource, codebase, package_adder)
| 537 | |
| 538 | @classmethod |
| 539 | def assemble(cls, package_data, resource, codebase, package_adder): |
| 540 | |
| 541 | package_resource = None |
| 542 | if resource.name == 'pyproject.toml': |
| 543 | package_resource = resource |
| 544 | elif resource.name == 'poetry.lock': |
| 545 | if resource.has_parent(): |
| 546 | siblings = resource.siblings(codebase) |
| 547 | package_resource = [r for r in siblings if r.name == 'pyproject.toml'] |
| 548 | if package_resource: |
| 549 | package_resource = package_resource[0] |
| 550 | |
| 551 | if not package_resource: |
| 552 | # we do not have a pyproject.toml |
| 553 | yield from yield_dependencies_from_package_resource(resource) |
| 554 | return |
| 555 | |
| 556 | if codebase.has_single_resource: |
| 557 | yield from models.DatafileHandler.assemble(package_data, resource, codebase, package_adder) |
| 558 | return |
| 559 | |
| 560 | assert len(package_resource.package_data) == 1, f'Invalid pyproject.toml for {package_resource.path}' |
| 561 | pkg_data = package_resource.package_data[0] |
| 562 | pkg_data = models.PackageData.from_dict(pkg_data) |
| 563 | |
| 564 | if pkg_data.purl: |
| 565 | package = models.Package.from_package_data( |
| 566 | package_data=pkg_data, |
| 567 | datafile_path=package_resource.path, |
| 568 | ) |
| 569 | package_uid = package.package_uid |
| 570 | package.populate_license_fields() |
| 571 | yield package |
| 572 | |
| 573 | root = package_resource.parent(codebase) |
| 574 | if root: |
| 575 | for pypi_res in cls.walk_pypi(resource=root, codebase=codebase): |
| 576 | if package_uid and package_uid not in pypi_res.for_packages: |
| 577 | package_adder(package_uid, pypi_res, codebase) |
| 578 | yield pypi_res |
| 579 | |
| 580 | yield package_resource |
| 581 | |
| 582 | else: |
| 583 | # we have no package, so deps are not for a specific package uid |
| 584 | package_uid = None |
| 585 | |
| 586 | # in all cases yield possible dependencies |
| 587 | yield from yield_dependencies_from_package_data(pkg_data, package_resource.path, package_uid) |
| 588 | |
| 589 | # we yield this as we do not want this further processed |
| 590 | yield package_resource |
| 591 | |
| 592 | for lock_file in package_resource.siblings(codebase): |
| 593 | if lock_file.name == 'poetry.lock': |
| 594 | yield from yield_dependencies_from_package_resource(lock_file, package_uid) |
| 595 | |
| 596 | if package_uid and package_uid not in lock_file.for_packages: |
nothing calls this directly
no test coverage detected