-
Notifications
You must be signed in to change notification settings - Fork 147
How to migrate from 0.6.1 to 0.7.0
Meret B edited this page Dec 12, 2022
·
6 revisions
Below is a (non-exhaustive) overview of changes in the new release that might require adjustments during migration:
- The class
Algorithmwas renamed toChecksum - Checksum fields in
FileandPackagewere renamed fromchk_sum/check_sumtochecksum
-
The classes
License,LicenseConjunction,LicenseDisjunction,ExtractedLicensewere moved to a separate filelicense.py-> imports need to be adapted, e.g.
from spdx.document import Licensetofrom spdx.license import License -
the function
calc_verif_codewas moved frompackage.pytoutils.py
- Files are saved at document-level. To map a file belonging to a package you need to add a
CONTAINSrelationship, e.g. instead of adding the file to the package
package.add_file(file_entry)
add the file at document level and create a new CONTAINS relationship
doc.add_file(file_entry)
relationship = Relationship(package.spdx_id + " CONTAINS " + file_entry.spdx_id)
doc.add_relationship(relationship)
-
Enums for
ChecksumAlgorithm,FileTypesandRelationshipTypewere introduced.- To build a
Checksumobject you need to use aChecksumAlgorithmobject asidentifier, e.g.
from spdx.checksum import ChecksumAlgorithm from spdx.checksum import Checksum new_checksum = Checksum(identifier=ChecksumAlgorithm.SHA1, value="85ed0817af83a24ad8da68c2b5094de69833983c")- To build a file with valid file types use a
FileTypeobject
from spdx.file import File from spdx.file import FileType file = File('./some/path/tofile') file.spdx_id = 'SPDXRef-File' file.file_types = [FileType.OTHER] - To build a
Further examples on how to build a valid document can be found in the provided test files, e.g. tests/test_document.py.