-
Notifications
You must be signed in to change notification settings - Fork 130
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
Auto-generate SPDX3 model to RDF graph converters for RDF serialization #726
Conversation
b97e4bb
to
55d602d
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.
Thanks, looks very good to me, just a few remarks.
return "Build" | ||
if module.startswith("spdx_tools.spdx3.model.software"): | ||
return "Software" | ||
return "Core" |
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.
Core
doesn't make sense to me as a default value.
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.
With the current manually written model classes, the core classes do not have their own subpackages within the spdx3.model package. So if they do not match any of the other namespace packages above, then "Core" is actually what remains.
if not clazz: | ||
return True | ||
if "SubclassOf" not in clazz["metadata"] or clazz["metadata"]["SubclassOf"] == "none" or clazz["metadata"]["SubclassOf"].startswith("xsd:"): | ||
return not clazz["properties"] |
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 assumes that we'll not have a non-literal base class without properties, doesn't it? Which will probably stay true.
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.
Perhaps it would be sufficient to check for subclasses of xsd types without properties. A class without any parent and without any properties probably doesn't make sense in the spdx spec, anyway.
|
||
|
||
def module_to_namespace(module: str) -> Optional[str]: | ||
if not module.startswith("spdx_tools.spdx3.model"): |
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.
When is this the case?
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.
For Python built-in types like str
and datetime
. Although it's possible that in the latest iteration of the generated code these cases no longer reach that function, I'd have to check.
a08c3dc
to
e82cb96
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.
Runs without error using the changes from spdx/spdx-3-model#399.
Thanks for the great work! :)
11d54ef
to
101abae
Compare
101abae
to
b322350
Compare
Signed-off-by: Holger Frydrych <holger.frydrych@tngtech.com>
Signed-off-by: Holger Frydrych <holger.frydrych@tngtech.com>
Signed-off-by: Holger Frydrych <holger.frydrych@tngtech.com>
Signed-off-by: Holger Frydrych <holger.frydrych@tngtech.com>
Signed-off-by: Holger Frydrych <holger.frydrych@tngtech.com>
Signed-off-by: Holger Frydrych <holger.frydrych@tngtech.com>
Signed-off-by: Holger Frydrych <holger.frydrych@tngtech.com>
…eral properties are treated as URIRefs; fixes shacl validation errors Signed-off-by: Holger Frydrych <holger.frydrych@tngtech.com>
Signed-off-by: Holger Frydrych <holger.frydrych@tngtech.com>
…should be objects Signed-off-by: Holger Frydrych <holger.frydrych@tngtech.com>
… writer test Signed-off-by: Holger Frydrych <holger.frydrych@tngtech.com>
Signed-off-by: Holger Frydrych <holger.frydrych@tngtech.com>
Signed-off-by: Holger Frydrych <holger.frydrych@tngtech.com>
Signed-off-by: Holger Frydrych <holger.frydrych@tngtech.com>
Signed-off-by: Holger Frydrych <holger.frydrych@tngtech.com>
Signed-off-by: Holger Frydrych <holger.frydrych@tngtech.com>
This is stale, and https://github.com/JPEWdev/shacl2code is expected to replace it |
This PR implements a draft for RDF serialization output. The RDF writer/converter is mostly auto-generated from the spec-parser's json dump of the spdx3 model.
Note: there are currently some issues in the spec where minCount/maxCount are not properly set for some properties, which leads to issues in the code generator as it incorrectly assumes these fields should be lists. Thes issues will need to be addressed in the spec or the spec-parser. In the meantime, you may have to manually set the maxCount for these fields in the json dump to '1'.
Known affected fields: CreationInfo::[specVersion, created, dataLicense]
Also: some classes in the licensing namespace currently use properties from ExpandedLicense, but are not referencing the namespace correctly. These are
subjectLicense
andsubjectAddition
. These have to be prefixed withExpandedLicense/
in the json dump manually until this issue is resolved in the spec.