Skip to content

Commit 65869ba

Browse files
committed
Don't delete prefixes used in imports
1 parent 9fe5c15 commit 65869ba

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

schema_automator/importers/rdfs_import_engine.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
SchemaDefinition,
1010
SlotDefinition,
1111
ClassDefinition,
12-
Prefix
12+
Prefix,
13+
Uriorcurie
1314
)
1415

1516
from dataclasses import dataclass, field
@@ -150,6 +151,10 @@ def convert(
150151
c.slots.append(identifier)
151152

152153
# Remove prefixes that aren't used
154+
if isinstance(schema.imports, list):
155+
for imp in schema.imports:
156+
prefix, suffix = imp.split(":", 1)
157+
self.seen_prefixes.add(prefix)
153158
schema.prefixes = {key: value for key, value in schema.prefixes.items() if key in self.seen_prefixes}
154159

155160
self.fix_missing(schema)
@@ -172,7 +177,7 @@ def fix_missing(self, schema: SchemaDefinition) -> None:
172177
logging.warning(f"Slot {slot.name} has subproperty_of {slot.subproperty_of}, but that slot is missing")
173178
slot.subproperty_of = None
174179

175-
def track_uri(self, uri: URIRef, g: Graph) -> None:
180+
def track_uri(self, uri: str, g: Graph) -> None:
176181
"""
177182
Updates the set of prefixes seen in the graph
178183
"""

0 commit comments

Comments
 (0)