tools-python
tools-python copied to clipboard
Question on UML Object model
Looking at https://raw.githubusercontent.com/spdx/spdx-spec/development/v2.2.1/ontology/SPDX-2.2.png it appears that a File object is accessible through the package object. However, my editor (notepad++) isn't seeing the File object, when I try to access with document.File - am I misunderstanding the object model at the above URL? Here is the python code I'm failing on: for fileName in document.package.file.fileNames : print(fileName.name)
Here is the spdx file I'm parsing: https://raw.githubusercontent.com/rjb4standards/REA-Products/master/SAG-PM.spdx
Any help to retrieve file info would be appreciated. Thanks in advance.
As seen from the data-model's package, package is associated with a list of files.
For accessing the files, you can do something like following:
for file in document.package.files:
print(file.name)
Thanks very much.
Closing this as the question was answered