Commit fb9677a8 authored by Noé Gaumont's avatar Noé Gaumont 🐙
Browse files

feat: use ExternalUri to store equivalent class

parent 23a9a5adb1e5
Pipeline #91655 failed with stages
in 5 minutes and 21 seconds
import subprocess
import re
import os
from pathlib import Path
import shutil
from typing import Iterable, Optional, List, Dict
from argparse import ArgumentParser
......@@ -18,6 +20,7 @@
from owl2yams.generate_postcreate import generate_postcreate
here = os.path.dirname(__file__)
LITERAL_TYPES_TO_YAMS_TYPES = {
RDFS.Literal: "String",
......@@ -178,22 +181,6 @@
)
)
if "CWUri" in schema:
raise ValueError("CWUri is reserved keyword, please rename it in your model")
cwuri_entitytype = schema.add_entity_type(EntityType("CWUri"))
if "cw_fragment" in schema:
raise ValueError(
"'cw_fragment' is reserved keyword, please rename it in your model"
)
cw_fragment_type = schema.add_relation_type(RelationType("cw_fragment"))
schema.add_relation_def(
RelationDefinition(cwuri_entitytype, cw_fragment_type, "String")
)
if "cw_uri" in schema:
raise ValueError("'cw_uri' is reserved keyword, please rename it in your model")
cw_uri_type = schema.add_relation_type(RelationType("cw_uri"))
schema.add_relation_def(RelationDefinition(cwuri_entitytype, cw_uri_type, "String"))
return schema, entitytype_fragment_to_uri, relationtype_fragment_to_uri
......@@ -268,6 +255,10 @@
run_and_print_if_error(create_cube)
cube_subfolder = cube_master_folder.replace("-", "_")
with open(f"{cube_master_folder}/{cube_subfolder}/schema.py", "a") as f:
model_schema_path = Path(f"{cube_master_folder}/{cube_subfolder}/schema/schema.py")
model_schema_path.parent.mkdir(parents=True, exist_ok=True)
with open(model_schema_path, "a") as f:
f.write(serialize_to_python(schema))
......@@ -272,5 +263,8 @@
f.write(serialize_to_python(schema))
base_schema_path = Path(f"{cube_master_folder}/{cube_subfolder}/schema/__init__.py")
shutil.copy(str(f"{here}/schema_uri.py"), str(base_schema_path))
with open(
f"{cube_master_folder}/{cube_subfolder}/migration/postcreate.py", "a"
) as f:
......
from yams.buildobjs import *
class equivalent_class(RelationDefinition):
subject = ("CWEType", "CWRelation")
object = ("ExternalUri",)
cardinality = "*?"
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