Skip to content

Commit 8de5550

Browse files
author
lukaspie
committed
allow optionally different output dir
1 parent 8ba02d4 commit 8de5550

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

script/generate_ontology.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
import os
55
import sys
66

7-
def main(full=False, testdata = False, nexus_def_path=None, def_commit=None, store_commit_filename = False, imports=[]):
7+
def main(full=False, testdata = False, nexus_def_path=None, def_commit=None, store_commit_filename = False, imports=[], output_dir=None):
88
print(f"Debug: Generating ontology with full={full} and testdata={testdata}")
9-
local_dir = os.path.abspath(os.path.dirname(__file__))
109
os.environ['NEXUS_DEF_PATH'] = nexus_def_path
1110

1211
# Official NeXus definitions: https://manual.nexusformat.org/classes/
@@ -36,7 +35,13 @@ def main(full=False, testdata = False, nexus_def_path=None, def_commit=None, sto
3635

3736
def_commit_text = f"_{def_commit}" if store_commit_filename else ""
3837
output_file_name = f"NeXusOntology{fullsuffix}{def_commit_text}.owl"
39-
output_path = os.path.join(local_dir, f"..{os.sep}ontology{os.sep}{output_file_name}")
38+
39+
if output_dir is None:
40+
output_dir = os.path.abspath(os.path.dirname(__file__))
41+
output_path = os.path.join(output_dir, f"..{os.sep}ontology{os.sep}{output_file_name}")
42+
else:
43+
output_path = os.path.join(output_dir, output_file_name)
44+
4045
onto.save(file=output_path, format="rdfxml")
4146

4247
if __name__ == "__main__":

0 commit comments

Comments
 (0)