Skip to content
Snippets Groups Projects
Commit e8fa01d9 authored by Valerio Mariani's avatar Valerio Mariani
Browse files

Added function to create soft links (Work by Tom Grant)

parent 46f39129
No related branches found
No related tags found
No related merge requests found
...@@ -287,7 +287,7 @@ class CXIWriter: ...@@ -287,7 +287,7 @@ class CXIWriter:
"""Writes a simple, non-stack entry in the file. """Writes a simple, non-stack entry in the file.
Writes a simple, non-stack entry in the file, at the specified path. A simple entry can be written at all times, Writes a simple, non-stack entry in the file, at the specified path. A simple entry can be written at all times,
before or after the stack initialization. THe user must provide a name that identifies the entry for further before or after the stack initialization. The user must provide a name that identifies the entry for further
operations (for example, creating a link). operations (for example, creating a link).
Args: Args:
...@@ -384,6 +384,31 @@ class CXIWriter: ...@@ -384,6 +384,31 @@ class CXIWriter:
self._fh[path] = link_target self._fh[path] = link_target
def create_softlink_to_group(self, group, path, overwrite=False):
"""Creates a link to an HDF5 group.
Creates a soft link to an HDF5 group (as opposed to a simple entry or stack). If a link or entry already exists at
the specified path, it is deleted and replaced only if the value of the overwrite parameter is True.
Args:
group (str): internal HDF5 path of the group to which the link points.
path (str): path in the hdf5 where the link is created.
overwrite (bool): if set to True, an entry already existing at the same location will be overwritten. If set
to False, an attempt to overwrite an entry will raise an error.
"""
if path in self._fh:
if overwrite is True:
del (self._fh[path])
else:
raise RuntimeError('Cannot create the link. An entry already exists at the specified path.')
self._fh[path] = h5py.SoftLink(group)
def initialize_stacks(self): def initialize_stacks(self):
"""Initializes the stacks. """Initializes the stacks.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment