Skip to content

Commit

Permalink
Change icatingest.py to use pathlib internally.
Browse files Browse the repository at this point in the history
  • Loading branch information
RKrahl committed Jul 13, 2020
1 parent bdc8a13 commit 1c16187
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions icatingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"]),
Expand All @@ -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."
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 1c16187

Please sign in to comment.