-
Notifications
You must be signed in to change notification settings - Fork 135
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
[Issue 359] Add Json writer for new data model #379
[Issue 359] Add Json writer for new data model #379
Conversation
e68d842
to
9045c5b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall I think it's a nice structure for the writer- eventhough I have to admit that I needed some time to get the bigger picture and to understand the functionality of the convertor and the role of the properties. Here are some comments from a first look.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very thorough implementation that takes a while to get used to but seems very OK :)
element_ids = [file.spdx_id for file in document.files] | ||
element_ids.extend([package.spdx_id for package in document.packages]) | ||
element_ids.extend([snippet.spdx_id for snippet in document.snippets]) | ||
document_annotations = filter(lambda annotation: annotation.spdx_id not in element_ids, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will add annotations with external spdx_id
s to the document.
I don't know how to properly write them out, though, as json does not support annotations with SPDX id references. Should we just discard them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, good question. Dropping them feels bad. But I don't see any solution that avoids losing information.
@goneall : The situation is that a SPDX document contains an annotation, where the annotated element is an external element. Where should the annotation go in the serialized json? The json schema puts annotations directly on the annotated element. This works fine for packages, files, snippets and the document itself, but there is no place for annotations targeting external elements.
def algorithm_to_json_string(algorithm: ChecksumAlgorithm) -> str: | ||
name_with_dash: str = algorithm.name.replace("_", "-") | ||
if "BLAKE2B" in name_with_dash: | ||
return name_with_dash.replace("BLAKE2B", "BLAKE2b") | ||
return name_with_dash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is needed in the tag-value writer, too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But that isn't merged yet, right? Then once this PR is merged, the other one can be rebased and can extract it
I discussed with @maxhbr that we want users to only write valid documents per default. This means that a validation step should be included in the writers that has to be explicitly toggled off if the user does not want that. |
8ac17fb
to
26fe138
Compare
There is now a |
0359001
to
26fe138
Compare
Signed-off-by: Nicolaus Weidner <nicolaus.weidner@tngtech.com>
Signed-off-by: Nicolaus Weidner <nicolaus.weidner@tngtech.com>
Signed-off-by: Nicolaus Weidner <nicolaus.weidner@tngtech.com>
…rties Signed-off-by: Nicolaus Weidner <nicolaus.weidner@tngtech.com>
…n separate converters), refactor document_properties.py to include all document properties instead of just top-level ones Signed-off-by: Nicolaus Weidner <nicolaus.weidner@tngtech.com>
Signed-off-by: Nicolaus Weidner <nicolaus.weidner@tngtech.com>
Signed-off-by: Nicolaus Weidner <nicolaus.weidner@tngtech.com>
Signed-off-by: Nicolaus Weidner <nicolaus.weidner@tngtech.com>
Signed-off-by: Nicolaus Weidner <nicolaus.weidner@tngtech.com>
Signed-off-by: Nicolaus Weidner <nicolaus.weidner@tngtech.com>
… for (upcoming) more complex conversion cases Signed-off-by: Nicolaus Weidner <nicolaus.weidner@tngtech.com>
Signed-off-by: Nicolaus Weidner <nicolaus.weidner@tngtech.com>
Signed-off-by: Nicolaus Weidner <nicolaus.weidner@tngtech.com>
Signed-off-by: Nicolaus Weidner <nicolaus.weidner@tngtech.com>
Signed-off-by: Nicolaus Weidner <nicolaus.weidner@tngtech.com>
Signed-off-by: Nicolaus Weidner <nicolaus.weidner@tngtech.com>
Signed-off-by: Nicolaus Weidner <nicolaus.weidner@tngtech.com>
Signed-off-by: Nicolaus Weidner <nicolaus.weidner@tngtech.com>
Signed-off-by: Nicolaus Weidner <nicolaus.weidner@tngtech.com>
… any additional properties Signed-off-by: Nicolaus Weidner <nicolaus.weidner@tngtech.com>
Signed-off-by: Nicolaus Weidner <nicolaus.weidner@tngtech.com>
Signed-off-by: Nicolaus Weidner <nicolaus.weidner@tngtech.com>
Signed-off-by: Nicolaus Weidner <nicolaus.weidner@tngtech.com>
Signed-off-by: Nicolaus Weidner <nicolaus.weidner@tngtech.com>
Signed-off-by: Nicolaus Weidner <nicolaus.weidner@tngtech.com>
…nverter Signed-off-by: Nicolaus Weidner <nicolaus.weidner@tngtech.com>
Signed-off-by: Nicolaus Weidner <nicolaus.weidner@tngtech.com>
Signed-off-by: Nicolaus Weidner <nicolaus.weidner@tngtech.com>
Signed-off-by: Nicolaus Weidner <nicolaus.weidner@tngtech.com>
Signed-off-by: Nicolaus Weidner <nicolaus.weidner@tngtech.com>
Signed-off-by: Nicolaus Weidner <nicolaus.weidner@tngtech.com>
…rter Signed-off-by: Nicolaus Weidner <nicolaus.weidner@tngtech.com>
…erter Signed-off-by: Nicolaus Weidner <nicolaus.weidner@tngtech.com>
Signed-off-by: Nicolaus Weidner <nicolaus.weidner@tngtech.com>
…sabling it Signed-off-by: Nicolaus Weidner <nicolaus.weidner@tngtech.com>
Signed-off-by: Nicolaus Weidner <nicolaus.weidner@tngtech.com>
Signed-off-by: Nicolaus Weidner <nicolaus.weidner@tngtech.com>
…a document Signed-off-by: Nicolaus Weidner <nicolaus.weidner@tngtech.com>
…validator.py Signed-off-by: Nicolaus Weidner <nicolaus.weidner@tngtech.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much, looks very good now :)
Fixes #359
Signed-off-by: Nicolaus Weidner nicolaus.weidner@tngtech.com