Populate a packages tally list of packages mappings. Note: `keep_details` is never used, as we are not keeping details of packages as this has no value.
(resource, children, keep_details=False)
| 456 | |
| 457 | |
| 458 | def package_tallies(resource, children, keep_details=False): |
| 459 | """ |
| 460 | Populate a packages tally list of packages mappings. |
| 461 | |
| 462 | Note: `keep_details` is never used, as we are not keeping details of |
| 463 | packages as this has no value. |
| 464 | """ |
| 465 | packages = [] |
| 466 | |
| 467 | # Collect current data |
| 468 | current_packages = getattr(resource, 'packages') or [] |
| 469 | |
| 470 | if TRACE_LIGHT and current_packages: |
| 471 | from packagedcode.models import Package |
| 472 | packs = [Package(**p) for p in current_packages] |
| 473 | logger_debug('package_tallier: for:', resource, |
| 474 | 'current_packages are:', packs) |
| 475 | |
| 476 | current_packages = add_files(current_packages, resource) |
| 477 | packages.extend(current_packages) |
| 478 | |
| 479 | if TRACE_LIGHT and packages: |
| 480 | logger_debug() |
| 481 | from packagedcode.models import Package # NOQA |
| 482 | packs = [Package(**p) for p in packages] |
| 483 | logger_debug('package_tallier: for:', resource, |
| 484 | 'packages are:', packs) |
| 485 | |
| 486 | # Collect direct children packages tallies |
| 487 | for child in children: |
| 488 | child_tallies = get_resource_tallies(child, key='packages', as_attribute=False) or [] |
| 489 | packages.extend(child_tallies) |
| 490 | |
| 491 | # summarize proper |
| 492 | set_resource_tallies(resource, key='packages', value=packages, as_attribute=False) |
| 493 | return packages |
nothing calls this directly
no test coverage detected