spdx_tools.spdx3.writer.console.software.package_writer

 1# SPDX-FileCopyrightText: 2023 spdx contributors
 2#
 3# SPDX-License-Identifier: Apache-2.0
 4from beartype.typing import TextIO
 5
 6from spdx_tools.spdx3.model.software import Package
 7from spdx_tools.spdx3.writer.console.artifact_writer import write_artifact_properties
 8from spdx_tools.spdx3.writer.console.console import write_value
 9
10
11def write_package(package: Package, text_output: TextIO, heading: bool = True):
12    if heading:
13        text_output.write("## Package\n")
14    write_artifact_properties(package, text_output)
15
16    for property_name in Package.__annotations__.keys():
17        if property_name == "package_purpose":
18            write_value(
19                property_name, ", ".join([purpose.name for purpose in getattr(package, property_name)]), text_output
20            )
21            continue
22        write_value(property_name, getattr(package, property_name), text_output)
def write_package( package: spdx_tools.spdx3.model.software.package.Package, text_output: <class 'TextIO'>, heading: bool = True):
12def write_package(package: Package, text_output: TextIO, heading: bool = True):
13    if heading:
14        text_output.write("## Package\n")
15    write_artifact_properties(package, text_output)
16
17    for property_name in Package.__annotations__.keys():
18        if property_name == "package_purpose":
19            write_value(
20                property_name, ", ".join([purpose.name for purpose in getattr(package, property_name)]), text_output
21            )
22            continue
23        write_value(property_name, getattr(package, property_name), text_output)