Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/spdx_tools/spdx/writer/tagvalue/tagvalue_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,7 @@ def write_document(document: Document, text_output: TextIO):
write_separator(text_output)
if package.spdx_id in contained_files_by_package_id:
for file in contained_files_by_package_id[package.spdx_id]:
if file.spdx_id in already_written_file_ids:
relationships_to_write.append(
Relationship(package.spdx_id, RelationshipType.CONTAINS, file.spdx_id)
)
else:
if file.spdx_id not in already_written_file_ids:
write_file(file, text_output)
write_separator(text_output)
if file.spdx_id in file_ids_with_contained_snippets:
Expand All @@ -89,6 +85,8 @@ def write_document(document: Document, text_output: TextIO):
)
already_written_file_ids.append(file.spdx_id)

relationships_to_write.append(Relationship(package.spdx_id, RelationshipType.CONTAINS, file.spdx_id))

write_optional_heading(document.extracted_licensing_info, "## License Information\n", text_output)
write_list_of_elements(
document.extracted_licensing_info, write_extracted_licensing_info, text_output, with_separator=True
Expand Down
3 changes: 3 additions & 0 deletions tests/spdx/writer/tagvalue/test_tagvalue_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ def test_correct_order_of_elements():
call("PackageDownloadLocation: \n"),
call("FilesAnalyzed: true\n"),
call("\n"),
call('## Relationships\n'),
call('Relationship: SPDXRef-Package-A CONTAINS SPDXRef-File-B\n'),
call("\n"),
]
)
Expand Down Expand Up @@ -215,6 +217,7 @@ def test_same_file_in_multiple_packages():
call("## Relationships\n"),
call("Relationship: SPDXRef-DOCUMENT DESCRIBES SPDXRef-Package-A\n"),
call("Relationship: SPDXRef-DOCUMENT DESCRIBES SPDXRef-Package-B\n"),
call("Relationship: SPDXRef-Package-A CONTAINS SPDXRef-File\n"),
call("Relationship: SPDXRef-Package-B CONTAINS SPDXRef-File\n"),
call("\n"),
]
Expand Down