Skip to content

Commit

Permalink
imagefiles: fixed case when fname is path
Browse files Browse the repository at this point in the history
  • Loading branch information
donald e. boyce committed Jan 14, 2024
1 parent 3271019 commit d56dfa3
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions hexrd/imageseries/load/imagefiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@ def __init__(self, fname):
Parameters
----------
fname: string | path
fname: string | Path
name of YAML file or bytestring of YAML contents
"""
self._fname = fname
self._load_yml()
Expand Down Expand Up @@ -93,15 +91,18 @@ def _load_yml(self):
MAXFILF = 'max-file-frames'
DTYPE = 'dtype'
#
# Check whether fname is a filename or YAML content. If it has multiple
# lines, we consider it to be content, otherwise a file name.
# Check whether fname is a pathlib Path, a filename or YAML content.
# If it has multiple lines, we consider it to be YAML content,
# otherwise a file name.
#
nlines = len(self.fname.splitlines())
is_str = isinstance(self.fname, str)
nlines = len(self.fname.splitlines()) if is_str else 1
if nlines > 1:
d = yaml.safe_load(self.fname)
else:
with open(self._fname, "r") as f:
d = yaml.safe_load(f)

imgsd = d['image-files']
dname = imgsd['directory']
fglob = imgsd['files']
Expand Down

0 comments on commit d56dfa3

Please sign in to comment.