Skip to content

Commit dc69bc6

Browse files
committed
Update doc and comments
Signed-off-by: Jono Yang <jyang@nexb.com>
1 parent 5ca30b1 commit dc69bc6

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

CHANGELOG.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ Important API changes:
6060
under the ``venv`` subdirectory. You mus be aware of this if you use ScanCode
6161
from a git clone
6262

63+
- ``DatafileHandler.assemble()``, ``DatafileHandler.assemble_from_many()``, and
64+
the other ``.assemble()``` methods from the other Package handlers from
65+
packagedcode, have been updated to yield Package items before Dependency or
66+
Resource items. This is particulary important in the case where we are calling
67+
the ``assemble()`` method outside of the scancode-toolkit context, where we
68+
need to ensure that a Package exists before we assocate a Resource or
69+
Dependency to it.
6370

6471
Copyright detection:
6572
~~~~~~~~~~~~~~~~~~~~

src/packagedcode/models.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -914,6 +914,12 @@ def assemble(cls, package_data, resource, codebase, package_adder=add_to_package
914914
not be further processed,
915915
- a Dependency to add to top-level dependencies
916916
917+
Package items must be yielded before Dependency or Resource items. This
918+
is to ensure that a Package is created before we associate a Resource or
919+
Dependency to a Package. This is particulary important in the case where
920+
we are calling the `assemble()` method outside of the scancode-toolkit
921+
context.
922+
917923
The approach is to find and process all the neighboring related datafiles
918924
to this datafile at once.
919925
@@ -1038,6 +1044,13 @@ def assemble_from_many(cls, pkgdata_resources, codebase, package_adder=add_to_pa
10381044
This is a convenience method that subclasses can reuse when overriding
10391045
`assemble()`
10401046
1047+
Like in ``DatafileHandler.assemble()``, Package items must be yielded
1048+
before Dependency or Resource items. This is to ensure that a Package is
1049+
created before we associate a Resource or Dependency to a Package. This
1050+
is particulary important in the case where we are calling the
1051+
``assemble()`` method outside of the scancode-toolkit context, as
1052+
``assemble()`` can call ``assemble_from_many()``.
1053+
10411054
NOTE: ATTENTION!: this may not work well for datafile that yield
10421055
multiple PackageData for unrelated Packages
10431056
"""

0 commit comments

Comments
 (0)