1- from typing import Optional , List , Union
1+ from pathlib import Path
2+ from typing import Optional , List , Union , Any
3+ from rdflib import Graph
24
35class Config :
46 """
@@ -47,7 +49,7 @@ class OntoEnv:
4749 def __init__ (
4850 self ,
4951 config : Optional [Config ] = None ,
50- path : Optional [Union [str , Path ]] = "." ,
52+ path : Optional [Union [str , Path ]] = None ,
5153 recreate : bool = False ,
5254 read_only : bool = False ,
5355 ) -> None :
@@ -62,22 +64,13 @@ class OntoEnv:
6264 """
6365 ...
6466
65- def is_read_only (self ) -> bool :
66- """
67- Check if the ontology environment is read-only.
68-
69- Returns:
70- A boolean indicating if the environment is read-only.
71- """
72- ...
73-
7467 def __repr__ (self ) -> str :
7568 """
7669 Return a string representation of the OntoEnv object.
7770 """
7871 ...
7972
80- def import_graph (self , destination_graph , uri : str ) -> None :
73+ def import_graph (self , destination_graph : Any , uri : str ) -> None :
8174 """
8275 Import a graph from the given URI into the destination graph.
8376
@@ -87,13 +80,13 @@ class OntoEnv:
8780 """
8881 ...
8982
90- def list_closure (self , uri : str ) -> List [str ]:
83+ def list_closure (self , uri : str , recursion_depth : int = - 1 ) -> List [str ]:
9184 """
9285 List the ontologies in the imports closure of the given ontology.
9386
9487 Args:
9588 uri: The URI of the ontology.
96-
89+ recursion_depth: The maximum depth for recursive import resolution.
9790 Returns:
9891 A list of ontology names in the closure.
9992 """
@@ -102,10 +95,11 @@ class OntoEnv:
10295 def get_closure (
10396 self ,
10497 uri : str ,
105- destination_graph : Optional = None ,
106- rewrite_sh_prefixes : bool = False ,
107- remove_owl_imports : bool = False ,
108- ) -> None :
98+ destination_graph : Optional [Any ] = None ,
99+ rewrite_sh_prefixes : bool = True ,
100+ remove_owl_imports : bool = True ,
101+ recursion_depth : int = - 1 ,
102+ ) -> tuple [Graph , List [str ]]:
109103 """
110104 Merge all graphs in the imports closure of the given ontology into a single graph.
111105
@@ -114,6 +108,9 @@ class OntoEnv:
114108 destination_graph: Optional graph to add the merged graph to.
115109 rewrite_sh_prefixes: Flag to rewrite SH prefixes.
116110 remove_owl_imports: Flag to remove OWL imports.
111+ recursion_depth: The maximum depth for recursive import resolution.
112+ Returns:
113+ A tuple containing the merged rdflib.Graph and a list of ontology names in the closure.
117114 """
118115 ...
119116
@@ -126,36 +123,59 @@ class OntoEnv:
126123 """
127124 ...
128125
129- def import_dependencies (self , graph ) -> None :
126+ def import_dependencies (self , graph : Any , recursion_depth : int = - 1 ) -> tuple [ Any , List [ str ]] :
130127 """
131128 Import the dependencies of the given graph into the graph.
132129
133130 Args:
134131 graph: The graph to import dependencies into.
132+ recursion_depth: The maximum depth for recursive import resolution.
133+ Returns:
134+ A tuple containing the updated rdflib.Graph and a list of imported ontology names.
135135 """
136136 ...
137137
138- def add (self , location ) -> None :
138+ def add (self , location : Any ) -> str :
139139 """
140140 Add a new ontology to the OntoEnv.
141141
142142 Args:
143- location: The location of the ontology to add.
143+ location: The location of the ontology to add (file path, URL, or rdflib.Graph).
144+ Returns:
145+ The URI string of the added ontology.
144146 """
145147 ...
146148
147- def refresh (self ) -> None :
149+ def add_no_imports (self , location : Any ) -> str :
150+ """
151+ Add a new ontology to the OntoEnv without exploring owl:imports.
152+
153+ Args:
154+ location: The location of the ontology to add (file path, URL, or rdflib.Graph).
155+ Returns:
156+ The URI string of the added ontology.
148157 """
149- Refresh the OntoEnv by re-loading all remote graphs and loading any local graphs which have changed.
158+ ...
159+
160+ def get_importers (self , uri : str ) -> List [str ]:
161+ """
162+ Get the names of all ontologies that import the given ontology.
163+
164+ Args:
165+ uri: The URI of the ontology.
166+ Returns:
167+ A list of ontology names that import the given ontology.
150168 """
151169 ...
152170
153- def get_graph (self , uri : str ) -> None :
171+ def get_graph (self , uri : str ) -> Graph :
154172 """
155173 Export the graph with the given URI to an rdflib.Graph.
156174
157175 Args:
158176 uri: The URI of the graph to export.
177+ Returns:
178+ An rdflib.Graph object representing the requested graph.
159179 """
160180 ...
161181
@@ -168,8 +188,87 @@ class OntoEnv:
168188 """
169189 ...
170190
171- def to_rdflib_dataset (self ) -> None :
191+ def to_rdflib_dataset (self ) -> Any :
172192 """
173193 Convert the OntoEnv to an rdflib.Dataset.
174194 """
175195 ...
196+
197+ # Config accessors
198+ def is_offline (self ) -> bool :
199+ """
200+ Checks if the environment is in offline mode.
201+ """
202+ ...
203+
204+ def set_offline (self , offline : bool ) -> None :
205+ """
206+ Sets the offline mode for the environment.
207+ """
208+ ...
209+
210+ def is_strict (self ) -> bool :
211+ """
212+ Checks if the environment is in strict mode.
213+ """
214+ ...
215+
216+ def set_strict (self , strict : bool ) -> None :
217+ """
218+ Sets the strict mode for the environment.
219+ """
220+ ...
221+
222+ def requires_ontology_names (self ) -> bool :
223+ """
224+ Checks if the environment requires unique ontology names.
225+ """
226+ ...
227+
228+ def set_require_ontology_names (self , require : bool ) -> None :
229+ """
230+ Sets whether the environment requires unique ontology names.
231+ """
232+ ...
233+
234+ def no_search (self ) -> bool :
235+ """
236+ Checks if the environment disables local file search.
237+ """
238+ ...
239+
240+ def set_no_search (self , no_search : bool ) -> None :
241+ """
242+ Sets whether the environment disables local file search.
243+ """
244+ ...
245+
246+ def resolution_policy (self ) -> str :
247+ """
248+ Returns the current resolution policy.
249+ """
250+ ...
251+
252+ def set_resolution_policy (self , policy : str ) -> None :
253+ """
254+ Sets the resolution policy for the environment.
255+ """
256+ ...
257+
258+ def store_path (self ) -> Optional [str ]:
259+ """
260+ Returns the path to the underlying graph store, if applicable.
261+ """
262+ ...
263+
264+ def close (self ) -> None :
265+ """
266+ Closes the ontology environment, saving changes and flushing the store.
267+ """
268+ ...
269+
270+ def flush (self ) -> None :
271+ """
272+ Flushes any pending writes to the underlying graph store.
273+ """
274+ ...
0 commit comments