spdx_tools.spdx.writer.tagvalue.relationship_writer

 1# SPDX-License-Identifier: Apache-2.0
 2#  Copyright (c) 2022 spdx contributors
 3#  Licensed under the Apache License, Version 2.0 (the "License");
 4#  you may not use this file except in compliance with the License.
 5#  You may obtain a copy of the License at
 6#    http://www.apache.org/licenses/LICENSE-2.0
 7#  Unless required by applicable law or agreed to in writing, software
 8#  distributed under the License is distributed on an "AS IS" BASIS,
 9#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10#  See the License for the specific language governing permissions and
11#  limitations under the License.
12from beartype.typing import TextIO
13
14from spdx_tools.spdx.model import Relationship
15from spdx_tools.spdx.writer.tagvalue.tagvalue_writer_helper_functions import write_text_value, write_value
16
17
18def write_relationship(relationship: Relationship, text_output: TextIO):
19    write_value(
20        "Relationship",
21        " ".join(
22            [
23                relationship.spdx_element_id,
24                relationship.relationship_type.name,
25                str(relationship.related_spdx_element_id),
26            ]
27        ),
28        text_output,
29    )
30    write_text_value("RelationshipComment", relationship.comment, text_output)
def write_relationship( relationship: spdx_tools.spdx.model.relationship.Relationship, text_output: <class 'TextIO'>):
19def write_relationship(relationship: Relationship, text_output: TextIO):
20    write_value(
21        "Relationship",
22        " ".join(
23            [
24                relationship.spdx_element_id,
25                relationship.relationship_type.name,
26                str(relationship.related_spdx_element_id),
27            ]
28        ),
29        text_output,
30    )
31    write_text_value("RelationshipComment", relationship.comment, text_output)