@@ -130,6 +130,8 @@ def from_rdf_graph(self, graph: Graph, schemaview: SchemaView, target_class: Typ
130130 # back to a text representation
131131 v = namespaces .curie_for (o )
132132 e = schemaview .get_enum (slot .range )
133+ if e is None :
134+ raise ValueError (f'no enum found for { slot .range } : { o } (ns={ v } )' )
133135 for pv in e .permissible_values .values ():
134136 if v == pv .meaning or str (o ) == pv .meaning :
135137 v = pv .text
@@ -169,9 +171,16 @@ def from_rdf_graph(self, graph: Graph, schemaview: SchemaView, target_class: Typ
169171 # Step 2: replace inline pointers with object dicts
170172 def repl (v ):
171173 if isinstance (v , Pointer ):
172- v2 = obj_map [ v .obj ]
174+ v2 = obj_map . get ( v .obj )
173175 if v2 is None :
174- raise Exception (f'No mapping for pointer { v } ' )
176+ msg = f'No mapping for pointer { v } . Triples:'
177+ for s , p , o in graph .triples ((None , None , v .obj )):
178+ for s2 , p2 , o2 in graph .triples ((None , None , s )):
179+ msg += f"\n { s2 } { p2 } { o2 } ."
180+ msg += f"\n { s } { p } { o } ."
181+ for s , p , o in graph .triples ((v .obj , None , None )):
182+ msg += f"\n { s } { p } { o } ."
183+ raise Exception (msg )
175184 return v2
176185 else :
177186 return v
0 commit comments