Skip to content

Commit

Permalink
Merge pull request #114 from dice-group/RefactoringManagers
Browse files Browse the repository at this point in the history
Fix for #112
  • Loading branch information
Demirrr authored Nov 25, 2024
2 parents 82b5ae9 + 460de76 commit d151f0d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
7 changes: 5 additions & 2 deletions owlapy/owl_ontology.py
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ class Ontology(AbstractOWLOntology):
_world: owlready2.World
is_modified: bool

def __init__(self, manager: _OM, ontology_iri: IRI, load: bool):
def __init__(self, manager: _OM, ontology_iri: IRI | str, load: bool):
"""Represents an Ontology in Ontolearn.
Args:
Expand All @@ -796,7 +796,10 @@ def __init__(self, manager: _OM, ontology_iri: IRI, load: bool):
self._iri = ontology_iri
self._world = manager._world
self.is_modified = False
onto = self._world.get_ontology(ontology_iri.as_str())
if isinstance(ontology_iri,str):
onto = self._world.get_ontology(ontology_iri)
else:
onto = self._world.get_ontology(ontology_iri.as_str())
if load:
onto = onto.load()
self._onto = onto
Expand Down
9 changes: 2 additions & 7 deletions owlapy/owl_ontology_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,8 @@ def create_ontology(self, iri: Union[str, IRI] = None) -> Ontology:
assert isinstance(iri, IRI), "iri either must be string or an instance of IRI Class"
return Ontology(self, iri, load=False)

def load_ontology(self, path: Union[IRI, str] = None) -> Ontology:
if isinstance(path, str):
path_iri = IRI.create(path)
else:
assert isinstance(path, IRI), "iri either must be string or an instance of IRI Class"
path_iri=path
return Ontology(self, path_iri, load=True)
def load_ontology(self, path: str = None) -> Ontology:
return Ontology(self, path, load=True)

def apply_change(self, change: AbstractOWLOntologyChange):
if isinstance(change, AddImport):
Expand Down

0 comments on commit d151f0d

Please sign in to comment.