From 1c124037a0886f83c8b48e80321c8e74e87abeed Mon Sep 17 00:00:00 2001
From: Mattia Mancini <mancini@astron.nl>
Date: Thu, 4 Oct 2018 08:36:43 +0000
Subject: [PATCH] SW-43: add support for attributes

---
 .../lib/datacontainers/holography_dataset.py          | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/CAL/CalibrationCommon/lib/datacontainers/holography_dataset.py b/CAL/CalibrationCommon/lib/datacontainers/holography_dataset.py
index 43d442171d3..24e42878cfc 100644
--- a/CAL/CalibrationCommon/lib/datacontainers/holography_dataset.py
+++ b/CAL/CalibrationCommon/lib/datacontainers/holography_dataset.py
@@ -361,6 +361,12 @@ class HolographyDataset():
         """
         starting_leaf = h5file[uri]
         result = dict()
+
+        # Read the attributes in the hdf5 dataset
+        result['ATTRIBUTES'] = dict()
+        for attribute_key, attribute_value in starting_leaf.attrs:
+            result['ATTRIBUTES'][attribute_key] = attribute_value
+
         for key, value in starting_leaf.items():
 
             if isinstance(value, h5py.Group) is True:
@@ -391,6 +397,11 @@ class HolographyDataset():
         else:
             starting_leaf = h5file[uri]
 
+        # Store the attributes in the hdf5 dataset
+        attributes = data_to_store.pop('ATTRIBUTES', dict())
+        for attribute_key, attribute_value in attributes.items():
+            starting_leaf.attrs[attribute_key] = attribute_value
+
         for key, value in data_to_store.items():
 
             if isinstance(value, dict) is True:
-- 
GitLab