diff --git a/icatingest.py b/icatingest.py index 81764b1c..62149b0b 100755 --- a/icatingest.py +++ b/icatingest.py @@ -4,7 +4,7 @@ # icatdump.py. import logging -import os.path +from pathlib import Path import icat import icat.config from icat.dumpfile import open_dumpfile @@ -38,7 +38,7 @@ type=icat.config.flag, default=False) config.add_variable('dataDir', ("--datafile-dir",), dict(help="datafile directory"), - default='.') + type=Path, default='.') config.add_variable('duplicate', ("--duplicate",), dict(help="behavior in case of duplicate objects", choices=["THROW", "IGNORE", "CHECK", "OVERWRITE"]), @@ -49,7 +49,7 @@ if conf.idsurl is None: raise icat.ConfigError("Config option 'idsurl' not given, " "but required for uploadDatafiles.") - conf.dataDir = os.path.abspath(conf.dataDir) + conf.dataDir = conf.dataDir.resolve() if client.apiversion < '4.3.0': raise RuntimeError("Sorry, ICAT version %s is too old, need 4.3.0 or newer." @@ -86,7 +86,7 @@ def check_duplicate(obj): with open_dumpfile(client, conf.file, conf.format, 'r') as dumpfile: for obj in dumpfile.getobjs(): if conf.uploadDatafiles and obj.BeanName == "Datafile": - fname = os.path.join(conf.dataDir, obj.name) + fname = conf.dataDir / obj.name client.putData(fname, obj) else: try: