Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
jkotan committed Nov 23, 2023
1 parent 4ff7953 commit f8d1961
Show file tree
Hide file tree
Showing 2 changed files with 492 additions and 23 deletions.
24 changes: 15 additions & 9 deletions nxstools/nxsfileinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -2172,7 +2172,7 @@ def groupmetadata(cls, options):
omfile = options.output
elif options.group and options.group[0]:
if imfile:
metadir, _ = os.path.split(imfile)
metadir, _ = os.path.split(os.path.abspath(imfile))
omfile = os.path.join(
metadir, "%s.scan.json" % options.group[0])
if options.writefiles:
Expand All @@ -2184,9 +2184,11 @@ def groupmetadata(cls, options):
odfile = options.dboutput
elif options.group and options.group[0]:
if imfile and os.path.isfile(imfile):
metadir, _ = os.path.split(imfile)
metadir, _ = os.path.split(os.path.abspath(imfile))
elif idfile:
metadir, _ = os.path.split(idfile)
metadir, _ = os.path.split(os.path.abspath(idfile))
elif omfile:
metadir, _ = os.path.split(os.path.abspath(omfile))
if metadir:
odfile = os.path.join(
metadir, "%s.origdatablock.json" % options.group[0])
Expand All @@ -2199,9 +2201,11 @@ def groupmetadata(cls, options):
oafile = options.atoutput
elif options.group and options.group[0]:
if imfile and os.path.isfile(imfile):
metadir, _ = os.path.split(imfile)
metadir, _ = os.path.split(os.path.abspath(imfile))
elif iafile:
metadir, _ = os.path.split(iafile)
metadir, _ = os.path.split(os.path.abspath(iafile))
elif omfile:
metadir, _ = os.path.split(os.path.abspath(omfile))
if metadir:
oafile = os.path.join(
metadir, "%s.attachment.json" % options.group[0])
Expand Down Expand Up @@ -2270,7 +2274,7 @@ def groupmetadata(cls, options):
dresult = [dresult]
except Exception:
dresult = []
if idfile and os.path.isfile(idfile):
if idfile and os.path.isfile(idfile) and idfile not in dresult:
dresult.append(idfile)

if oafile and os.path.isfile(oafile):
Expand All @@ -2282,7 +2286,7 @@ def groupmetadata(cls, options):
aresult = [dresult]
except Exception:
aresult = []
if iafile and os.path.isfile(iafile):
if iafile and os.path.isfile(iafile) and iafile not in aresult:
aresult.append(iafile)

jsnresult = None
Expand Down Expand Up @@ -2325,6 +2329,8 @@ def opener(path, flags):
else:
with open(options.output, "w") as fl:
fl.write(metadata)
else:
print(metadata)
if options.dboutput:
chmod = None
try:
Expand All @@ -2350,6 +2356,8 @@ def opener(path, flags):
else:
with open(options.dboutput, "w") as fl:
fl.write(datablocks)
else:
print(datablocks)
if options.atoutput:
chmod = None
try:
Expand All @@ -2376,8 +2384,6 @@ def opener(path, flags):
with open(options.atoutput, "w") as fl:
fl.write(attachments)
else:
print(metadata)
print(datablocks)
print(attachments)
except Exception as e:
sys.stderr.write("nxsfileinfo: '%s'\n"
Expand Down
Loading

0 comments on commit f8d1961

Please sign in to comment.