-
Notifications
You must be signed in to change notification settings - Fork 134
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
Algorithm
was renamed toChecksum
- Checksum fields in
File
andPackage
were renamed fromchk_sum
/check_sum
tochecksum
-
The classes
License
,LicenseConjunction
,LicenseDisjunction
,ExtractedLicense
were moved to a separate filelicense.py
-> imports need to be adapted, e.g.
from spdx.document import License
tofrom spdx.license import License
-
the function
calc_verif_code
was moved frompackage.py
toutils.py
- Files are saved at document-level. To map a file belonging to a package you need to add a
CONTAINS
relationship, 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
,FileTypes
andRelationshipType
were introduced.- To build a
Checksum
object you need to use aChecksumAlgorithm
object 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
FileType
object
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
.