Skip to content

Conversation

@armintaenzertng
Copy link
Collaborator

fixes #388

parsing output uses the tag-value writer to output to stdout

src/formats.py Outdated
YAML = auto()
XML = auto()
TAG_VALUE = auto()
RDF = auto()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RDF or RDF_XML?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use these interchangeably, but RDF_XML is more precise, I guess. Fixed.

if validate:
validation_messages: List[ValidationMessage] = validate_full_spdx_document(document, version)
if validation_messages:
print("The document is invalid. The following issues have been found:")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If not valid, the cli should exit with 1

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parser and converter have been merged into a single tool.

print("Please note that this project is currently undergoing a major refactoring and therefore missing "
"a few features which will be added in time.\n"
"In the meanwhile, please use the current PyPI release version 0.7.0.")
return
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in case of error, it should also exit with 1

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parser and converter have been merged into a single tool.

document: Document = parse_file(file)
except NotImplementedError as err:
print(err.args[0])
print("Please note that this project is currently undergoing a major refactoring and therefore missing "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe link to the issues?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

write_file(document, outfile)
except NotImplementedError as err:
print(err.args[0])
print("Please note that this project is currently undergoing a major refactoring and therefore missing "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also here: on error exit with code 1

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

def main(file, force):
@click.option("--version", prompt="SPDX version", help="The SPDX version to be used during validation")
@click.option("--validate", is_flag=True, help="validate the provided document")
@click.option("--printout", is_flag=True, help="print the parsed document to stdout in tag-value format")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a pure debug option?

An often seen convention, to print to stdout, is to use the argument -. So -o - implies output is stdout.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@click.option("--version", prompt="SPDX version", help="The SPDX version to be used during validation")
@click.option("--validate", is_flag=True, help="validate the provided document")
@click.option("--printout", is_flag=True, help="print the parsed document to stdout in tag-value format")
def main(file, version, validate, printout):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is there a parser and a converter? I think they both could be the same tool.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parser and converter have been merged into a single tool.

@armintaenzertng armintaenzertng merged commit a9b6525 into spdx:refactor-python-tools Jan 4, 2023
@armintaenzertng armintaenzertng deleted the newCLI branch January 4, 2023 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants