
    G@d
                         d Z ddlZddlZej                            d          rd Zd ZndZdZedk    r2g ddd	Z	 e
 ee	d
                      e
 ed
                     dS dS )a  
I/O plugin for loading/saving HDF5 files.

Note that this is a fairly dumb implementation which reads the whole HDF5 file into
Spyder's variable explorer.  Since HDF5 files are designed for storing very large
data-sets, it may be much better to work directly with the HDF5 objects, thus keeping
the data on disk.  Nonetheless, this plugin gives quick and dirty but convenient
access to HDF5 files.

There is no support for creating files with compression, chunking etc, although
these can be read without problem.

All datatypes to be saved must be convertible to a numpy array, otherwise an exception
will be raised.

Data attributes are currently ignored.

When reading an HDF5 file with sub-groups, groups in the HDF5 file will
correspond to dictionaries with the same layout.  However, when saving
data, dictionaries are not turned into HDF5 groups.

TODO: Look for the pytables library if h5py is not found??
TODO: Check issues with valid python names vs valid h5f5 names
    Nh5pyc                     dd l fd	                     | d          } |          }|                                 |d fS # t          $ r}d t	          |          fcY d }~S d }~ww xY w)Nr   c                     i }t          |                                           D ]U\  }}t          |j                  rt	          j        |          ||<   2t          |j                  r |          ||<   V|S )N)listitems
isinstanceDatasetnparrayGroup)groupcontentsnameobj	get_groupr   s       =lib/python3.11/site-packages/spyder/plugins/io_hdf5/plugin.pyr   zload_hdf5.<locals>.get_group,   s}    H!%++--00 4 4	cc4<00 4%'Xc]]HTNNTZ00 4%.Ys^^HTNO    r)r   Fileclose	Exceptionstr)filenamefr   errorr   r   s       @@r   	load_hdf5r   *   s    		 		 		 		 		 			$		(C((A y||HGGIIIT>! 	$ 	$ 	$U#######	$s   8A 
A,A'!A,'A,c                 ,   dd l }	 |                    |d          }t          |                                           D ]\  }}t	          j        |          ||<   |                                 d S # t          $ r}t          |          cY d }~S d }~ww xY w)Nr   w)	r   r   r   r   r
   r   r   r   r   )datar   r   r   keyvaluer   s          r   	save_hdf5r"   ?   s    			(C((A"4::<<00 ) )
U%#GGIIIII 	 	 	u::	s   A(A0 0
B:BBB__main__)            g      @)abztest.h5)__doc__	importlibnumpyr
   util	find_specr   r"   __name__r   print r   r   <module>r2      s    2        >F## !$ $ $*    II z,,c**D	E))D)
$
$%%%	E))I

 r   