Skip to content
Snippets Groups Projects
Commit 6f834823d046 authored by Fabien Amarger's avatar Fabien Amarger
Browse files

fix: Blackify

parent 3f5f1b465d80
No related branches found
No related tags found
No related merge requests found
......@@ -12,11 +12,11 @@
ETYPE_URI = {}
LITERAL_TYPES_TO_YAMS_TYPES = {
RDFS.Literal: 'String',
XSD.string: 'String',
XSD.int: 'Int',
XSD.integer: 'Int',
XSD.float: 'Float',
RDFS.Literal: "String",
XSD.string: "String",
XSD.int: "Int",
XSD.integer: "Int",
XSD.float: "Float",
}
......@@ -50,10 +50,12 @@
entity_schema = schema._entities[class_fragment]
ETYPE_URI[class_fragment] = class_uri
superior_classes = []
for _, _, superior_class_uri in owl_model.triples((class_uri, RDFS.subClassOf, None)):
for _, _, superior_class_uri in owl_model.triples(
(class_uri, RDFS.subClassOf, None)
):
superior_classes.append(fragment_from_uri(superior_class_uri))
if superior_classes:
entity_schema._specialized_type = ", ".join(superior_classes)
# 2. fetch all datatype properties
......@@ -54,10 +56,14 @@
superior_classes.append(fragment_from_uri(superior_class_uri))
if superior_classes:
entity_schema._specialized_type = ", ".join(superior_classes)
# 2. fetch all datatype properties
for datatype_property_uri, _, _, in owl_model.triples((None, RDF.type, OWL.DatatypeProperty)):
for (
datatype_property_uri,
_,
_,
) in owl_model.triples((None, RDF.type, OWL.DatatypeProperty)):
datatype_property_uri_fragment = fragment_from_uri(datatype_property_uri)
schema.add_relation_type(RelationType(datatype_property_uri_fragment))
# take first range, if no range use RDFS.Literal
......@@ -61,5 +67,8 @@
datatype_property_uri_fragment = fragment_from_uri(datatype_property_uri)
schema.add_relation_type(RelationType(datatype_property_uri_fragment))
# take first range, if no range use RDFS.Literal
_, _, literal_type = next(owl_model.triples((datatype_property_uri, RDFS.range, None)), (_, _, RDFS.Literal))
_, _, literal_type = next(
owl_model.triples((datatype_property_uri, RDFS.range, None)),
(_, _, RDFS.Literal),
)
yams_type = LITERAL_TYPES_TO_YAMS_TYPES[literal_type]
......@@ -65,3 +74,5 @@
yams_type = LITERAL_TYPES_TO_YAMS_TYPES[literal_type]
for _, _, domain_uri in owl_model.triples((datatype_property_uri, RDFS.domain, None)):
for _, _, domain_uri in owl_model.triples(
(datatype_property_uri, RDFS.domain, None)
):
domain_uri_fragment = fragment_from_uri(domain_uri)
......@@ -67,4 +78,8 @@
domain_uri_fragment = fragment_from_uri(domain_uri)
schema.add_relation_def(RelationDefinition(domain_uri_fragment, datatype_property_uri_fragment, yams_type))
schema.add_relation_def(
RelationDefinition(
domain_uri_fragment, datatype_property_uri_fragment, yams_type
)
)
print(serialize_to_python(schema))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment