8000 [issue-402] add validation option to tag-value writer by meretp · Pull Request #536 · spdx/tools-python · GitHub
[go: up one dir, main page]

Skip to content

[issue-402] add validation option to tag-value writer #536

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
[issue-402] drop spdx version as input argument as it is automaticall…
…y inferred from the creation_info

Signed-off-by: Meret Behrens <meret.behrens@tngtech.com>
  • Loading branch information
meretp committed Mar 28, 2023
commit 84c2fb450aa4a0942fa22555834c75dbead1ebc2
3 changes: 1 addition & 2 deletions src/spdx/writer/rdf/rdf_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@

def write_document_to_file(document: Document, file_name: str, validate: bool):
if validate:
validation_messages: List[ValidationMessage] = validate_full_spdx_document(document,
8000 document.creation_info.spdx_version)
validation_messages: List[ValidationMessage] = validate_full_spdx_document(document)
if validation_messages:
raise ValueError(f"Document is not valid. The following errors were detected: {validation_messages}")

Expand Down
3 changes: 1 addition & 2 deletions src/spdx/writer/tagvalue/tagvalue_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@

def write_document_to_file(document: Document, file_name: str, validate: bool = True):
if validate:
validation_messages: List[ValidationMessage] = validate_full_spdx_document(document,
document.creation_info.spdx_version)
validation_messages: List[ValidationMessage] = validate_full_spdx_document(document)
if validation_messages:
raise ValueError(f"Document is not valid. The following errors were detected: {validation_messages}")

Expand Down
6 changes: 3 additions & 3 deletions src/spdx/writer/xml/xml_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
from spdx.validation.validation_message import ValidationMessage


def write_document_to_file(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 XML 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,
a new one is created.
"""
if validate:
validation_messages: List[ValidationMessage] = validate_full_spdx_document(document,
document.creation_info.spdx_version)
validation_messages: List[ValidationMessage] = validate_full_spdx_document(document)
if validation_messages:
raise ValueError(f"Document is not valid. The following errors were detected: {validation_messages}")
if converter is None:
Expand Down
6 changes: 3 additions & 3 deletions src/spdx/writer/yaml/yaml_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
from spdx.validation.validation_message import ValidationMessage


def write_document_to_file(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 yaml 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,
a new one is created.
"""
if validate:
validation_messages: List[ValidationMessage] = validate_full_spdx_document(document,
document.creation_info.spdx_version)
validation_messages: List[ValidationMessage] = validate_full_spdx_document(document)
if validation_messages:
raise ValueError(f"Document is not valid. The following errors were detected: {validation_messages}")
if converter is None:
Expand Down
0