tools-python icon indicating copy to clipboard operation
tools-python copied to clipboard

Question on UML Object model

Open rjb4standards opened this issue 4 years ago • 2 comments

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.

rjb4standards avatar Sep 08 '20 21:09 rjb4standards

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)

RishabhBhatnagar avatar Sep 09 '20 04:09 RishabhBhatnagar

Thanks very much.

rjb4standards avatar Sep 09 '20 14:09 rjb4standards

Closing this as the question was answered

nicoweidner avatar Oct 19 '22 09:10 nicoweidner