From a1af9eb1c93e6eea2fee80db2821e55818d73584 Mon Sep 17 00:00:00 2001 From: Thomas Kluyver <thomas@kluyver.me.uk> Date: Wed, 29 Nov 2023 19:14:26 +0100 Subject: [PATCH] Don't write creationDate & updateDate unless specified --- src/cal_tools/files.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/cal_tools/files.py b/src/cal_tools/files.py index 8decff781..edb73070c 100644 --- a/src/cal_tools/files.py +++ b/src/cal_tools/files.py @@ -310,16 +310,14 @@ class DataFile(h5py.File): if sequence is None: sequence = self.__sequence - if creation_date is None: - creation_date = datetime.now() - if update_date is None: update_date = creation_date md_group = self.require_group('METADATA') - md_group.create_dataset( - 'creationDate', shape=(1,), - data=creation_date.strftime('%Y%m%dT%H%M%SZ').encode('ascii')) + if creation_date is not None: + md_group.create_dataset( + 'creationDate', shape=(1,), + data=creation_date.strftime('%Y%m%dT%H%M%SZ').encode('ascii')) md_group.create_dataset('daqLibrary', shape=(1,), data=daq_library.encode('ascii')) md_group.create_dataset('dataFormatVersion', shape=(1,), data=b'1.2') @@ -360,9 +358,10 @@ class DataFile(h5py.File): 'runNumber', shape=(1,), dtype=np.uint32, data=run) md_group.create_dataset( 'sequenceNumber', shape=(1,), dtype=np.uint32, data=sequence) - md_group.create_dataset( - 'updateDate', shape=(1,), - data=update_date.strftime('%Y%m%dT%H%M%SZ').encode('ascii')) + if update_date is not None: + md_group.create_dataset( + 'updateDate', shape=(1,), + data=update_date.strftime('%Y%m%dT%H%M%SZ').encode('ascii')) class ControlSource(h5py.Group): -- GitLab