Commit bdfd1008 authored by Fabien Amarger's avatar Fabien Amarger
Browse files

feat: generate with RDFadapter

parent 2ca485d5f673
Pipeline #92217 failed with stages
in 50 seconds
......@@ -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}/", "a") as f:
schema, entitytype_fragment_to_uri, relationtype_fragment_to_uri
if args.only_cube:
print("Cube correctly initialized")
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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment