spdx_tools.spdx.writer.write_anything
1# SPDX-FileCopyrightText: 2022 spdx contributors 2# 3# SPDX-License-Identifier: Apache-2.0 4from spdx_tools.spdx.formats import FileFormat, file_name_to_format 5from spdx_tools.spdx.model import Document 6from spdx_tools.spdx.writer.json import json_writer 7from spdx_tools.spdx.writer.rdf import rdf_writer 8from spdx_tools.spdx.writer.tagvalue import tagvalue_writer 9from spdx_tools.spdx.writer.xml import xml_writer 10from spdx_tools.spdx.writer.yaml import yaml_writer 11 12 13def write_file(document: Document, file_name: str, validate: bool = True): 14 output_format = file_name_to_format(file_name) 15 if output_format == FileFormat.JSON: 16 json_writer.write_document_to_file(document, file_name, validate) 17 elif output_format == FileFormat.YAML: 18 yaml_writer.write_document_to_file(document, file_name, validate) 19 elif output_format == FileFormat.XML: 20 xml_writer.write_document_to_file(document, file_name, validate) 21 elif output_format == FileFormat.TAG_VALUE: 22 tagvalue_writer.write_document_to_file(document, file_name, validate) 23 elif output_format == FileFormat.RDF_XML: 24 rdf_writer.write_document_to_file(document, file_name, validate)
def
write_file( document: spdx_tools.spdx.model.document.Document, file_name: str, validate: bool = True):
14def write_file(document: Document, file_name: str, validate: bool = True): 15 output_format = file_name_to_format(file_name) 16 if output_format == FileFormat.JSON: 17 json_writer.write_document_to_file(document, file_name, validate) 18 elif output_format == FileFormat.YAML: 19 yaml_writer.write_document_to_file(document, file_name, validate) 20 elif output_format == FileFormat.XML: 21 xml_writer.write_document_to_file(document, file_name, validate) 22 elif output_format == FileFormat.TAG_VALUE: 23 tagvalue_writer.write_document_to_file(document, file_name, validate) 24 elif output_format == FileFormat.RDF_XML: 25 rdf_writer.write_document_to_file(document, file_name, validate)