Closed JonoYang closed 2 years ago
re:
A solution would be to create a method on the Resource class named for_packages_append that appends a package_uid to Resource.for_packages
This can work.
An alternative could be use a new Codebase argument that would be the Resource class to use... today this class is crafted based on the provided attributes https://github.com/nexB/commoncode/blob/d3eed9acb55e2437205e54746a8a7e9f0307f249/src/commoncode/resource.py#L402
Another possibility could be to add and pass a add_to_package(resource, ...)
method as an argument to the assemble(..., package_adder=add_to_package, ...)
functions?
With a default that would be using a list-backed implementation... and then in SCIO you would have a Django db-backed implmentation of the same function and you would call it when you call assemble?
Another possibility could be to add and pass a add_to_package(resource, ...) method as an argument to the assemble(..., package_adder=add_to_package, ...) functions? With a default that would be using a list-backed implementation... and then in SCIO you would have a Django db-backed implmentation of the same function and you would call it when you call assemble?
I like this approach better than the one I posted before. It makes more sense to pass in the package adding function as an argument into assemble
than to add a method to Resource
that deals with an attribute that may not be there.
This has been implemented and merged in https://github.com/nexB/scancode-toolkit/pull/3035 Thanks!
We are updating the application package scanning process on scancode.io in https://github.com/nexB/scancode.io/issues/447. We are implementing the package assembly step from scancode-toolkit in scancode.io. The assembly methods from packagedcode associates Resources to packages by appending the
package_uid
to thefor_packages
attribute on Resources. This method of associating Resources to Packages does not work on scancode.io becausefor_packages
is an property onCodebaseResource
that generates a list of purls fromDiscoveredPackage
s associated with aCodebaseResource
.A solution would be to create a method on the
Resource
class namedfor_packages_append
that appends apackage_uid
toResource.for_packages
. This extra level of indirection allows us to create a different implementation onCodebaseResource
for associating Packages to Resources using the same interface.