allow to use '~' in filenames
no idea how to test, but seems to work
This commit is contained in:
parent
1147b5b742
commit
135f2e7add
|
@ -144,7 +144,7 @@ class Config(dict):
|
||||||
Configuration from file.
|
Configuration from file.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
fhandle = open(fname) if isinstance(fname, (str, Path)) else \
|
fhandle = open(Path(fname).expanduser()) if isinstance(fname, (str, Path)) else \
|
||||||
fname
|
fname
|
||||||
|
|
||||||
return cls(yaml.safe_load(fhandle))
|
return cls(yaml.safe_load(fhandle))
|
||||||
|
@ -163,7 +163,7 @@ class Config(dict):
|
||||||
Keyword arguments parsed to yaml.dump.
|
Keyword arguments parsed to yaml.dump.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
fhandle = open(fname,'w',newline='\n') if isinstance(fname, (str, Path)) else \
|
fhandle = open(Path(fname).expanduser(),'w',newline='\n') if isinstance(fname, (str, Path)) else \
|
||||||
fname
|
fname
|
||||||
|
|
||||||
if 'width' not in kwargs:
|
if 'width' not in kwargs:
|
||||||
|
|
|
@ -587,7 +587,7 @@ def DREAM3D_base_group(fname: Union[str, Path]) -> str:
|
||||||
Path to the base group.
|
Path to the base group.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
with h5py.File(fname,'r') as f:
|
with h5py.File(Path(fname).expanduser(),'r') as f:
|
||||||
base_group = f.visit(lambda path: path.rsplit('/',2)[0] if '_SIMPL_GEOMETRY/SPACING' in path else None)
|
base_group = f.visit(lambda path: path.rsplit('/',2)[0] if '_SIMPL_GEOMETRY/SPACING' in path else None)
|
||||||
|
|
||||||
if base_group is None:
|
if base_group is None:
|
||||||
|
@ -615,7 +615,7 @@ def DREAM3D_cell_data_group(fname: Union[str, Path]) -> str:
|
||||||
|
|
||||||
"""
|
"""
|
||||||
base_group = DREAM3D_base_group(fname)
|
base_group = DREAM3D_base_group(fname)
|
||||||
with h5py.File(fname,'r') as f:
|
with h5py.File(Path(fname).expanduser(),'r') as f:
|
||||||
cells = tuple(f['/'.join([base_group,'_SIMPL_GEOMETRY','DIMENSIONS'])][()][::-1])
|
cells = tuple(f['/'.join([base_group,'_SIMPL_GEOMETRY','DIMENSIONS'])][()][::-1])
|
||||||
cell_data_group = f[base_group].visititems(lambda path,obj: path.split('/')[0] \
|
cell_data_group = f[base_group].visititems(lambda path,obj: path.split('/')[0] \
|
||||||
if isinstance(obj,h5py._hl.dataset.Dataset) and np.shape(obj)[:-1] == cells \
|
if isinstance(obj,h5py._hl.dataset.Dataset) and np.shape(obj)[:-1] == cells \
|
||||||
|
|
Loading…
Reference in New Issue