Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cubicweb
OWL2YAMS
Commits
bdfd1008cb1b
Commit
bdfd1008
authored
Oct 29, 2021
by
Fabien Amarger
Browse files
feat: generate entities.py with RDFadapter
parent
2ca485d5f673
Pipeline
#92217
failed with stages
in 50 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
owl2yams/__init__.py
View file @
bdfd1008
...
...
@@ -19,6 +19,7 @@
)
from
owl2yams.generate_postcreate
import
generate_postcreate
from
owl2yams.generate_entities
import
generate_entities
here
=
os
.
path
.
dirname
(
__file__
)
...
...
@@ -274,6 +275,12 @@
)
)
with
open
(
f
"
{
cube_master_folder
}
/
{
cube_subfolder
}
/entities.py"
,
"a"
)
as
f
:
f
.
write
(
generate_entities
(
schema
,
entitytype_fragment_to_uri
,
relationtype_fragment_to_uri
)
)
if
args
.
only_cube
:
print
(
"Cube correctly initialized"
)
exit
(
0
)
...
...
owl2yams/generate_entities.py
0 → 100644
View file @
bdfd1008
from
yams.schema
import
Schema
from
typing
import
Dict
def
generate_entities
(
schema
:
Schema
,
entitytype_fragment_to_uri
:
Dict
[
str
,
str
],
relationtype_fragment_to_uri
:
Dict
[
str
,
str
],
)
->
str
:
entities_py_content
=
"""
from cubicweb.entities.adapters import EntityRDFAdapter
from rdflib import URIRef, OWL
"""
for
fragment
,
uri
in
entitytype_fragment_to_uri
.
items
():
entities_py_content
+=
f
"""
class
{
fragment
}
RDFAdapter(EntityRDFAdapter):
def triples(self):
yield from super().triples()
yield(URIRef("
{
uri
}
"), OWL.sameAs, URIRef(self.uri))
"""
return
entities_py_content
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment