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

Function add_to_package

src/packagedcode/models.py:1007–1020  ·  view source on GitHub ↗

Append `package_uid` to `resource.for_packages`, if the attribute exists and `package_uid` is not already in `resource.for_packages`.

(package_uid, resource, codebase)

Source from the content-addressed store, hash-verified

1005
1006
1007def add_to_package(package_uid, resource, codebase):
1008 """
1009 Append `package_uid` to `resource.for_packages`, if the attribute exists and
1010 `package_uid` is not already in `resource.for_packages`.
1011 """
1012 if (
1013 hasattr(resource, 'for_packages')
1014 and isinstance(resource.for_packages, list)
1015 and package_uid
1016 ):
1017 if package_uid in resource.for_packages:
1018 return
1019 resource.for_packages.append(package_uid)
1020 resource.save(codebase)
1021
1022
1023class DatafileHandler:

Callers

nothing calls this directly

Calls 2

appendMethod · 0.45
saveMethod · 0.45

Tested by

no test coverage detected