
    d.*                        d Z ddlZddlZddlZdZ	  G d de          Ze                                  G d de          Z	 G d d	e          Z
 G d
 de          Z G d dee          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d  d!e          Z G d" d#e          ZdS )$z>Declare exceptions and warnings that are specific to PyTables.    NreStructuredTextc                   T     e Zd ZdZdZdZ	 ed             Z fdZ fdZ	ddZ
 xZS )	HDF5ExtErrora  A low level HDF5 operation failed.

    This exception is raised the low level PyTables components used for
    accessing HDF5 files.  It usually signals that something is not
    going well in the HDF5 library or even at the Input/Output level.

    Errors in the HDF5 C library may be accompanied by an extensive
    HDF5 back trace on standard error (see also
    :func:`tables.silence_hdf5_messages`).

    .. versionchanged:: 2.4

    Parameters
    ----------
    message
        error message
    h5bt
        This parameter (keyword only) controls the HDF5 back trace
        handling. Any keyword arguments other than h5bt is ignored.

        * if set to False the HDF5 back trace is ignored and the
          :attr:`HDF5ExtError.h5backtrace` attribute is set to None
        * if set to True the back trace is retrieved from the HDF5
          library and stored in the :attr:`HDF5ExtError.h5backtrace`
          attribute as a list of tuples
        * if set to "VERBOSE" (default) the HDF5 back trace is
          stored in the :attr:`HDF5ExtError.h5backtrace` attribute
          and also included in the string representation of the
          exception
        * if not set (or set to None) the default policy is used
          (see :attr:`HDF5ExtError.DEFAULT_H5_BACKTRACE_POLICY`)

    NVERBOSEc                     ddddddd}| j         }t          j                            dd          }	 ||                                         }|| _         n'# t
          $ r t          j        d|z             Y nw xY w|S )NFTr   )IGNOREFALSESAVETRUEr   DEFAULTPT_DEFAULT_H5_BACKTRACE_POLICYr   zInvalid value for the environment variable 'PT_DEFAULT_H5_BACKTRACE_POLICY'.  The default policy for HDF5 back trace management in PyTables will be: '%s')DEFAULT_H5_BACKTRACE_POLICYosenvirongetupperKeyErrorwarningswarn)clsenvmapoldvalueenvvaluenewvalues        1lib/python3.11/site-packages/tables/exceptions.pyset_policy_from_envz HDF5ExtError.set_policy_from_envK   s       
 
 2:>>"BINN	7hnn../H /7C++  	6 	6 	6M * -55 6 6 6 6 6	6 s   A !A87A8c                      t                      j        |  |                    d| j                  | _        | j        r"| j        |                                 | _        d S d | _        d S )Nh5bt)super__init__r   r   _h5bt_policy_dump_h5_backtraceh5backtrace)selfargskargs	__class__s      r   r    zHDF5ExtError.__init__c   sq    $!IIfd.NOO 	$!8!D#6688D 0  $D    c                    t          | j        dv           }|r| j        rd                    d|                                 dg          }t          | j                  dk    rHt          | j        d         t                    r(t                      
                                }| d| }nO| j        d         d         r| d| j        d         d          }n#|}n t                      
                                }|S )	zReturns a sting representation of the exception.

        The actual result depends on policy set in the initializer
        :meth:`HDF5ExtError.__init__`.

        .. versionadded:: 2.4

        )r   verbose
zHDF5 error back trace
zEnd of HDF5 error back trace   r   z

)boolr!   r#   joinformat_h5_backtracelenr%   
isinstancestrr   __str__)r$   r*   btmsgr'   s       r   r4   zHDF5ExtError.__str__   s    t(,BBCC 	$t' 	$)((**.  B 49~~""z$)A,'D'D"ggoo''&&&&!"%b) ;;!1"!5b!9;;''//##C
r(   c                 j    || j         }|dS d                    t          j        |                    S )zConvert the HDF5 trace back represented as a list of tuples.
        (see :attr:`HDF5ExtError.h5backtrace`) into a string.

        .. versionadded:: 2.4

        NzNo HDF5 back trace available )r#   r/   	tracebackformat_list)r$   	backtraces     r   r0   z HDF5ExtError.format_h5_backtrace   s;     (I117790;;<<<r(   )N)__name__
__module____qualname____doc__r"   r   classmethodr   r    r4   r0   __classcell__)r'   s   @r   r   r      s           J "+,   [. $  $  $  $  $D    >= = = = = = = =r(   r   c                       e Zd ZdZdS )ClosedNodeErrorzThe operation can not be completed because the node is closed.

    For instance, listing the children of a closed group is not allowed.

    Nr<   r=   r>   r?    r(   r   rC   rC                	Dr(   rC   c                       e Zd ZdZdS )ClosedFileErrorzThe operation can not be completed because the hosting file is closed.

    For instance, getting an existing node from a closed file is not
    allowed.

    NrD   rE   r(   r   rH   rH                	Dr(   rH   c                       e Zd ZdZdS )FileModeErrorzThe operation can not be carried out because the mode in which the
    hosting file is opened is not adequate.

    For instance, removing an existing leaf from a read-only file is not
    allowed.

    NrD   rE   r(   r   rK   rK                	Dr(   rK   c                       e Zd ZdZdS )	NodeErrora  Invalid hierarchy manipulation operation requested.

    This exception is raised when the user requests an operation on the
    hierarchy which can not be run because of the current layout of the
    tree.  This includes accessing nonexistent nodes, moving or copying
    or creating over an existing node, non-recursively removing groups
    with children, and other similarly invalid operations.

    A node in a PyTables database cannot be simply overwritten by
    replacing it.  Instead, the old node must be removed explicitely
    before another one can take its place.  This is done to protect
    interactive users from inadvertedly deleting whole trees of data by
    a single erroneous command.

    NrD   rE   r(   r   rN   rN      s           	Dr(   rN   c                       e Zd ZdZdS )NoSuchNodeErrorzAn operation was requested on a node that does not exist.

    This exception is raised when an operation gets a path name or a
    ``(where, name)`` pair leading to a nonexistent node.

    NrD   rE   r(   r   rP   rP      rI   r(   rP   c                       e Zd ZdZdS )UndoRedoErrorzProblems with doing/redoing actions with Undo/Redo feature.

    This exception indicates a problem related to the Undo/Redo
    mechanism, such as trying to undo or redo actions with this
    mechanism disabled, or going to a nonexistent mark.

    NrD   rE   r(   r   rR   rR      rL   r(   rR   c                       e Zd ZdZdS )UndoRedoWarningzIssued when an action not supporting Undo/Redo is run.

    This warning is only shown when the Undo/Redo mechanism is enabled.

    NrD   rE   r(   r   rT   rT     rF   r(   rT   c                       e Zd ZdZdS )NaturalNameWarninga  Issued when a non-pythonic name is given for a node.

    This is not an error and may even be very useful in certain
    contexts, but one should be aware that such nodes cannot be
    accessed using natural naming (instead, ``getattr()`` must be
    used explicitly).
    NrD   rE   r(   r   rV   rV     rL   r(   rV   c                       e Zd ZdZdS )PerformanceWarningzWarning for operations which may cause a performance drop.

    This warning is issued when an operation is made on the database
    which may cause it to slow down on future operations (i.e. making
    the node tree grow too much).

    NrD   rE   r(   r   rX   rX     rL   r(   rX   c                       e Zd ZdZdS )FlavorErrorzUnsupported or unavailable flavor or flavor conversion.

    This exception is raised when an unsupported or unavailable flavor
    is given to a dataset, or when a conversion of data between two
    given flavors is not supported nor available.

    NrD   rE   r(   r   rZ   rZ   )  rL   r(   rZ   c                       e Zd ZdZdS )FlavorWarninga`  Unsupported or unavailable flavor conversion.

    This warning is issued when a conversion of data between two given
    flavors is not supported nor available, and raising an error would
    render the data inaccessible (e.g. on a dataset of an unavailable
    flavor in a read-only file).

    See the `FlavorError` class for more information.

    NrD   rE   r(   r   r\   r\   5  s        	 	 	Dr(   r\   c                       e Zd ZdZdS )FiltersWarningzUnavailable filters.

    This warning is issued when a valid filter is specified but it is
    not available in the system.  It may mean that an available default
    filter is to be used instead.

    NrD   rE   r(   r   r^   r^   D  rL   r(   r^   c                       e Zd ZdZdS )OldIndexWarningzUnsupported index format.

    This warning is issued when an index in an unsupported format is
    found.  The index will be marked as invalid and will behave as if
    doesn't exist.

    NrD   rE   r(   r   r`   r`   P  rL   r(   r`   c                       e Zd ZdZdS )DataTypeWarningzUnsupported data type.

    This warning is issued when an unsupported HDF5 data type is found
    (normally in a file created with other tool than PyTables).

    NrD   rE   r(   r   rb   rb   \  rI   r(   rb   c                       e Zd ZdZdS )ExperimentalFeatureWarningzGeneric warning for experimental features.

    This warning is issued when using a functionality that is still
    experimental and that users have to use with care.

    NrD   rE   r(   r   rd   rd   g  s          	Dr(   rd   )r?   r   r   r9   __docformat__RuntimeErrorr   r   
ValueErrorrC   rH   rK   AttributeErrorLookupErrorrN   rP   	ExceptionrR   WarningrT   rV   rX   rZ   r\   r^   r`   rb   rd   rE   r(   r   <module>rl      s   D D 				      # 9e= e= e= e= e=< e= e= e=R      " " "	 	 	 	 	j 	 	 		 	 	 	 	j 	 	 			 		 		 		 		J 		 		 			 	 	 	 	 	 	 	(	 	 	 	 	i 	 	 			 		 		 		 		I 		 		 			 	 	 	 	g 	 	 			 		 		 		 		 		 		 				 		 		 		 		 		 		 				 		 		 		 		* 		 		 			 	 	 	 	G 	 	 			 		 		 		 		W 		 		 				 		 		 		 		g 		 		 			 	 	 	 	g 	 	 		 	 	 	 	 	 	 	 	 	r(   