diff --git a/src/spdx/writer/json/json_writer.py b/src/spdx/writer/json/json_writer.py index 68f435cd8..6a11671ce 100644 --- a/src/spdx/writer/json/json_writer.py +++ b/src/spdx/writer/json/json_writer.py @@ -10,7 +10,9 @@ from spdx.validation.validation_message import ValidationMessage -def write_document(document: Document, file_name: str, validate: bool = True, converter: DocumentConverter = None): +def write_document_to_file( + document: Document, file_name: str, validate: bool = True, converter: DocumentConverter = None +): """ Serializes the provided document to json and writes it to a file with the provided name. Unless validate is set to False, validates the document before serialization. Unless a DocumentConverter instance is provided, diff --git a/src/spdx/writer/write_anything.py b/src/spdx/writer/write_anything.py index 06ca4aa11..87a8e08a2 100644 --- a/src/spdx/writer/write_anything.py +++ b/src/spdx/writer/write_anything.py @@ -13,7 +13,7 @@ def write_file(document: Document, file_name: str, validate: bool = True): output_format = file_name_to_format(file_name) if output_format == FileFormat.JSON: - json_writer.write_document(document, file_name, validate) + json_writer.write_document_to_file(document, file_name, validate) elif output_format == FileFormat.YAML: yaml_writer.write_document_to_file(document, file_name, validate) elif output_format == FileFormat.XML: diff --git a/tests/spdx/writer/json/test_json_writer.py b/tests/spdx/writer/json/test_json_writer.py index d17484e04..ee6013275 100644 --- a/tests/spdx/writer/json/test_json_writer.py +++ b/tests/spdx/writer/json/test_json_writer.py @@ -6,7 +6,7 @@ import pytest -from spdx.writer.json.json_writer import write_document +from spdx.writer.json.json_writer import write_document_to_file from tests.spdx.fixtures import document_fixture @@ -19,7 +19,7 @@ def temporary_file_path() -> str: def test_write_json(temporary_file_path: str): document = document_fixture() - write_document(document, temporary_file_path, validate=True) + write_document_to_file(document, temporary_file_path, validate=True) with open(temporary_file_path) as written_file: written_json = json.load(written_file) @@ -35,7 +35,7 @@ def test_document_is_validated(): document.creation_info.spdx_id = "InvalidId" with pytest.raises(ValueError) as error: - write_document(document, "dummy_path") + write_document_to_file(document, "dummy_path") assert "Document is not valid" in error.value.args[0] @@ -43,4 +43,4 @@ def test_document_validation_can_be_overridden(temporary_file_path: str): document = document_fixture() document.creation_info.spdx_id = "InvalidId" - write_document(document, temporary_file_path, validate=False) + write_document_to_file(document, temporary_file_path, validate=False)