Skip to content

Commit 78c959b

Browse files
Prevent ontoconvert from crashing when the --iri option is given (#902)
# Description Prevent ontoconvert from crashing unintentionally when the --iri option is given. Include also some minor code cleanup. ## Type of change <!-- Put an `x` in the box that applies. --> - [ ] Bug fix. - [ ] New feature. - [ ] Documentation update. - [ ] Test update. ## Checklist <!-- Put an `x` in the boxes that apply. You can also fill these out after creating the PR. --> This checklist can be used as a help for the reviewer. - [ ] Is the code easy to read and understand? - [ ] Are comments for humans to read, not computers to disregard? - [ ] Does a new feature has an accompanying new test (in the CI or unit testing schemes)? - [ ] Has the documentation been updated as necessary? - [ ] Does this close the issue? - [ ] Is the change limited to the issue? - [ ] Are errors handled for all outcomes? - [ ] Does the new feature provide new restrictions on dependencies, and if so is this documented? ## Comments <!-- Additional comments here, including clarifications on checklist if applicable. --> Co-authored-by: Francesca L. Bleken <48128015+francescalb@users.noreply.github.com>
1 parent 2d765eb commit 78c959b

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

ontopy/utils.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
if TYPE_CHECKING:
3535
from typing import Optional, Union
3636

37+
from ontopy import Ontology
38+
3739

3840
# Preferred language
3941
PREFERRED_LANGUAGE = "en"
@@ -860,14 +862,20 @@ def recur(o):
860862
return layout
861863

862864

863-
def copy_annotation(onto, src, dst):
865+
def copy_annotation(onto: "Ontology", src: str, dst: str):
864866
"""In all classes and properties in `onto`, copy annotation `src` to `dst`.
865867
866868
Arguments:
867869
onto: Ontology to work on.
868870
src: Name of source annotation.
869871
dst: Name or IRI of destination annotation. Use IRI if the
870872
destination annotation is not already in the ontology.
873+
874+
Example:
875+
876+
copy_annotation(
877+
onto, "elucidation", "http://www.w3.org/2000/01/rdf-schema#comment"
878+
)
871879
"""
872880
if onto.world[src]:
873881
src = onto.world[src]

tools/ontoconvert

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ def main(argv: list = None):
191191
action="store_true",
192192
help=(
193193
"Whether to annotate all entities with the base IRI of the source "
194-
"ontology using `dcterms:source` relations. This is contextual "
194+
"ontology using `rdfs:isDefinedBy` relations. This is contextual "
195195
"information that is otherwise lost when ontologies are inferred "
196196
"and/or squashed."
197197
),
@@ -274,7 +274,7 @@ def main(argv: list = None):
274274
if args.iri:
275275
onto.iri = args.iri
276276

277-
if args.base_iri:
277+
if args.base_iri and args.base_iri != onto.base_iri:
278278
onto.base_iri = args.base_iri
279279

280280
if args.annotate_source:

0 commit comments

Comments
 (0)