@@ -160,6 +160,7 @@ def format_prefixes(prefixes: dict, formatted_prefixes: dict | None = None) -> d
160160 formatted_prefixes = {}
161161 for prefix , namespace in prefixes .items ():
162162 formatted_prefixes .setdefault (namespace , []).append (prefix + ":" )
163+
163164 return formatted_prefixes
164165
165166 def get_prefixes (self ) -> dict :
@@ -180,7 +181,6 @@ def get_prefixes(self) -> dict:
180181 if not prefixes_cc or not self .prefix_cc :
181182 with (Path (__path__ [0 ]) / "prefix_cc.json" ).open ("r" , encoding = "utf-8" ) as json_file :
182183 prefixes_cc = json .load (json_file )
183-
184184 if prefixes_cc :
185185 prefixes = self .format_prefixes (prefixes_cc , prefixes )
186186
@@ -214,13 +214,11 @@ def get_name(self, iri: str) -> str:
214214 except IndexError as exc :
215215 raise IndexError (f"{ title_json ['title' ]} { prefixes } " ) from exc
216216 title += f" ({ prefix } )"
217-
218217 return title
219218
220219 def init_shapes_graph (self ) -> Graph :
221220 """Initialize SHACL shapes graph"""
222- shapes_graph = Graph ()
223- shapes_graph .add ((URIRef (self .shapes_graph_iri ), RDF .type , SHUI .ShapeCatalog ))
221+ shapes_graph = Graph ().add ((URIRef (self .shapes_graph_iri ), RDF .type , SHUI .ShapeCatalog ))
224222 shapes_graph .add (
225223 (
226224 URIRef (self .shapes_graph_iri ),
@@ -240,6 +238,7 @@ def iri_list_to_filter(iris: list[str], name: str = "property", filter_: str = "
240238 if not iris :
241239 return ""
242240 iris_quoted = [f"<{ _ } >" for _ in iris ]
241+
243242 return f"FILTER (?{ name } { filter_ } ({ ', ' .join (iris_quoted )} ))"
244243
245244 def get_class_dict (self ) -> dict :
@@ -292,6 +291,7 @@ def create_shapes(self, shapes_graph: Graph) -> tuple[Graph, int]:
292291 node_shape_uri = URIRef (f"{ format_namespace (self .shapes_graph_iri )} { class_uuid } " )
293292
294293 if class_uuid not in class_uuids :
294+ shapes_count += 1
295295 shapes_graph .add ((node_shape_uri , RDF .type , SH .NodeShape ))
296296 shapes_graph .add ((node_shape_uri , SH .targetClass , URIRef (cls )))
297297 name = self .get_name (cls )
@@ -304,7 +304,6 @@ def create_shapes(self, shapes_graph: Graph) -> tuple[Graph, int]:
304304 NAMESPACE_URL , f"{ prop ['property' ]} { 'inverse' if prop ['inverse' ] else '' } "
305305 )
306306 property_shape_uri = URIRef (f"{ format_namespace (self .shapes_graph_iri )} { prop_uuid } " )
307-
308307 if prop_uuid not in prop_uuids :
309308 shapes_count += 1
310309 name = self .get_name (prop ["property" ])
@@ -332,7 +331,6 @@ def create_shapes(self, shapes_graph: Graph) -> tuple[Graph, int]:
332331 shapes_graph .add ((property_shape_uri , SH .name , Literal (name , lang = "en" )))
333332 shapes_graph .add ((property_shape_uri , RDFS .label , Literal (name , lang = "en" )))
334333 prop_uuids .add (prop_uuid )
335-
336334 shapes_graph .add ((node_shape_uri , SH .property , property_shape_uri ))
337335
338336 return shapes_graph , shapes_count
0 commit comments