@@ -35,24 +35,26 @@ def parse_all_relationships(self, input_doc_dict: Dict) -> List[Relationship]:
3535 document_describes : List [str ] = delete_duplicates_from_list (input_doc_dict .get ("documentDescribes" , []))
3636 doc_spdx_id : Optional [str ] = input_doc_dict .get ("SPDXID" )
3737
38+ existing_relationships_without_comments : List [Relationship ] = self .get_all_relationships_without_comments (relationships )
3839 relationships .extend (
3940 parse_field_or_log_error (
4041 self .logger ,
4142 document_describes ,
4243 lambda x : self .parse_document_describes (
43- doc_spdx_id = doc_spdx_id , described_spdx_ids = x , existing_relationships = relationships
44+ doc_spdx_id = doc_spdx_id , described_spdx_ids = x , existing_relationships = existing_relationships_without_comments
4445 ),
4546 [],
4647 )
4748 )
4849
4950 package_dicts : List [Dict ] = input_doc_dict .get ("packages" , [])
51+ existing_relationships_without_comments : List [Relationship ] = self .get_all_relationships_without_comments (relationships )
5052
5153 relationships .extend (
5254 parse_field_or_log_error (
5355 self .logger ,
5456 package_dicts ,
55- lambda x : self .parse_has_files (package_dicts = x , existing_relationships = relationships ),
57+ lambda x : self .parse_has_files (package_dicts = x , existing_relationships = existing_relationships_without_comments ),
5658 [],
5759 )
5860 )
@@ -151,13 +153,11 @@ def parse_has_files(
151153 def check_if_relationship_exists (
152154 self , relationship : Relationship , existing_relationships : List [Relationship ]
153155 ) -> bool :
154- existing_relationships_without_comments : List [Relationship ] = self .get_all_relationships_without_comments (
155- existing_relationships
156- )
157- if relationship in existing_relationships_without_comments :
156+ # assume existing relationships are stripped of comments
157+ if relationship in existing_relationships :
158158 return True
159159 relationship_inverted : Relationship = self .invert_relationship (relationship )
160- if relationship_inverted in existing_relationships_without_comments :
160+ if relationship_inverted in existing_relationships :
161161 return True
162162
163163 return False
0 commit comments