From 4aeac16f29c47b86ddaea7dda5ae78d664a8c2fa Mon Sep 17 00:00:00 2001 From: Valerio Mariani <valerio.mariani@desy.de> Date: Fri, 18 Aug 2017 17:42:50 +0200 Subject: [PATCH] Added function to check if an entry is already present in the file. Fixed a typo --- cfel_cxi.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/cfel_cxi.py b/cfel_cxi.py index ebdb5b9..ccb4beb 100644 --- a/cfel_cxi.py +++ b/cfel_cxi.py @@ -492,6 +492,29 @@ class CXIWriter: return self._initialized + def is_entry_in_file(self, path): + """Checks if an entry is already present in the file. + + Checks if an entry is already present in the file at the path provided by the user. It will return True if + either a dataset or a group are present at the specified path + + Args: + + path (str): the path where to check for a dataset or group + + Results: + + ret (bool): True if a group or dataset can be found in the file, False otherwise + + """ + + if path in self._fh: + ret = True + else: + ret = False + + return ret + def file_is_full(self): """Checks if the file is full. @@ -505,7 +528,7 @@ class CXIWriter: return self._curr_slice >= self._max_num_slices - def num_slices_in_file(selfself): + def num_slices_in_file(self): """Returns the number of slices already written in the file Returns the number of slices that have already been written in the file. -- GitLab