def __init__(self, name, parent='/', attrs=None, children=None): """ Parameters ---------- name : String Name of the data group parent : (Optional) String HDF5 path to the parent of this object. Typically used when appending to an existing HDF5 file Default value assumes that this group sits at the root of the file attrs : dict (Optional). Default = None Attributes to be attached to the h5py.Group object children : VirtualData or list of VirtualData objects. (Optional) Children can be a mixture of groups and datasets """ warn( 'VirtualGroup is available only for legacy purposes and will be REMOVED in a future release.\n' 'Please consider using a combination of functions in :module:`pyUSID.io.hdf_utils` such as ' ':meth:`pyUSID.io.hdf_utils.create_results_group` instead', DeprecationWarning) super(VirtualGroup, self).__init__(name, parent, attrs=attrs) self.children = list() self.attrs['machine_id'] = socket.getfqdn() self.attrs['timestamp'] = get_time_stamp() self.indexed = False if name != '': self.indexed = self.name[-1] == '_' if children is not None: self.add_children(children)
def verify_book_keeping_attrs(test_class, h5_obj): time_stamp = get_time_stamp() in_file = h5_obj.attrs['timestamp'] test_class.assertEqual(time_stamp[:time_stamp.rindex('_')], in_file[:in_file.rindex('_')]) test_class.assertEqual(__version__, h5_obj.attrs['pyUSID_version']) test_class.assertEqual(socket.getfqdn(), h5_obj.attrs['machine_id']) test_class.assertEqual(platform(), h5_obj.attrs['platform'])
def get_time_stamp(): """ Teturns the current date and time as a string formatted as: Year_Month_Dat-Hour_Minute_Second Parameters ---------- Returns ------- String """ warn( 'pyUSID.io.io_utils.get_time_stamp has been moved to ' 'sidpy.base.string_utils.get_time_stamp. This copy in pyUSID will' 'be removed in future release. Please update your import statements', FutureWarning) return sut.get_time_stamp()
def write_book_keeping_attrs(h5_obj): """ Writes basic book-keeping and posterity related attributes to groups created using sidpy such as machine id, version, timestamp. Parameters ---------- h5_obj : :class:`h5py.Dataset`, :class:`h5py.Group`, or :class:`h5py.File` Object to which basic book-keeping attributes need to be written """ if not isinstance(h5_obj, (h5py.Group, h5py.File, h5py.Dataset)): raise TypeError( 'h5_obj should be a h5py.Group, h5py.File, or h5py.Dataset object') write_simple_attrs(h5_obj, { 'machine_id': socket.getfqdn(), 'timestamp': get_time_stamp(), 'platform': platform(), 'sidpy_version': sidpy_version }, verbose=False)