
    Kg 3                    6   d Z ddlmZ ddlZddlZddlZddlmZ g dZdZ		  G d de
      Zej                           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  G d' d(e      Z! G d) d*e      Z" G d+ d,e"      Z# G d- d.e"      Z$ G d/ d0e"      Z%y)1z>Declare exceptions and warnings that are specific to PyTables.    )annotationsN)Callable)
ChunkErrorClosedFileErrorClosedNodeErrorDataTypeWarningExperimentalFeatureWarningFileModeErrorFiltersWarningFlavorErrorFlavorWarningHDF5ExtErrorNaturalNameWarningNoSuchChunkErrorNoSuchNodeError	NodeErrorNotChunkedErrorNotChunkAlignedErrorOldIndexWarningPerformanceWarningUnclosedFileWarningUndoRedoErrorUndoRedoWarningreStructuredTextc                  j     e Zd ZU dZdZded<   dZ	 ed
d       Zd fdZ	d
 fdZ
	 d	 	 	 dd	Z xZS )r   a  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`)

    Nz4Callable[[], list[tuple[str, int, str, str]]] | None_dump_h5_backtraceVERBOSEc                    ddddddd}| j                   }t        j                  j                  dd      }	 ||j	                            }|| _         |S # t
        $ r t        j                  d|z         Y |S w xY w)z*Set the policy from environment variables.FTr   )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.12/site-packages/tables/exceptions.pyset_policy_from_envz HDF5ExtError.set_policy_from_envh   s       
 22::>>"BIN
	7hnn./H /7C+  	MM  #++ 	s   A !A87A8c                    t        |   |  |j                  d| j                        | _        | j                  r"| j
                  | j                         | _        y d | _        y )Nh5bt)super__init__r(   r%   _h5bt_policyr   h5backtrace)selfargskargs	__class__s      r2   r7   zHDF5ExtError.__init__   s]    $!IIfd.N.NO!8!8!D#668D0  $D    c                   t        | j                  dv       }|r| j                  rdj                  d| j	                         dg      }t        | j                        dk(  r4t        | j                  d   t              rt        | )         }| d| }|S | j                  d   d   r| d| j                  d   d    }|S |}|S t        | )         }|S )	zReturn 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

)boolr8   r9   joinformat_h5_backtracelenr;   
isinstancestrr6   __str__)r:   r@   btmsgr=   s       r2   rJ   zHDF5ExtError.__str__   s     t((,BBCt''-,,.2B 499~"z$))A,'Dgo'D& 
 !!"%b)D!1!1"!5b!9 :; 
	  
 '/#C
r>   c                l    || j                   }|ydj                  t        j                  |            S )zConvert the HDF5 trace back into a string.

        The HDF5 trace back is represented as a list of tuples.

        See :attr:`HDF5ExtError.h5backtrace`.

        .. versionadded:: 2.4

        zNo HDF5 back trace available )r9   rE   	tracebackformat_list)r:   	backtraces     r2   rF   z HDF5ExtError.format_h5_backtrace   s8     ((I177900;<<r>   )returnrI   )rR   None)N)rQ   z&list[tuple[str, int, str, str]] | NonerR   rI   )__name__
__module____qualname____doc__r   __annotations__r%   classmethodr3   r7   rJ   rF   __classcell__)r=   s   @r2   r   r   '   sd     N 	 < #,,  4 $DB CG=?=	=r>   r   c                      e Zd ZdZy)r   zThe operation can not be completed because the node is closed.

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

    NrT   rU   rV   rW    r>   r2   r   r           	r>   r   c                      e Zd ZdZy)r   zThe operation can not be completed because the hosting file is closed.

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

    Nr\   r]   r>   r2   r   r           	r>   r   c                      e Zd ZdZy)r
   zFIle mode error.

    The 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.

    Nr\   r]   r>   r2   r
   r
           	r>   r
   c                      e Zd ZdZy)r   a  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 explicitly
    before another one can take its place.  This is done to protect
    interactive users from inadvertently deleting whole trees of data by
    a single erroneous command.

    Nr\   r]   r>   r2   r   r     s      	r>   r   c                      e Zd ZdZy)r   zAn 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.

    Nr\   r]   r>   r2   r   r     r`   r>   r   c                      e Zd ZdZy)r   zProblems 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.

    Nr\   r]   r>   r2   r   r   $       	r>   r   c                      e Zd ZdZy)r   zIssued when an action not supporting Undo/Redo is run.

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

    Nr\   r]   r>   r2   r   r   0  r^   r>   r   c                      e Zd ZdZy)r   a  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).
    Nr\   r]   r>   r2   r   r   :  rf   r>   r   c                      e Zd ZdZy)r   zWarning 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).

    Nr\   r]   r>   r2   r   r   F  rf   r>   r   c                      e Zd ZdZy)r   zUnsupported 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.

    Nr\   r]   r>   r2   r   r   R  rf   r>   r   c                      e Zd ZdZy)r   a`  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.

    Nr\   r]   r>   r2   r   r   ^  s    	 	r>   r   c                      e Zd ZdZy)r   zUnavailable 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.

    Nr\   r]   r>   r2   r   r   m  rf   r>   r   c                      e Zd ZdZy)r   zUnsupported 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
    it doesn't exist.

    Nr\   r]   r>   r2   r   r   y  rf   r>   r   c                      e Zd ZdZy)r   zUnsupported data type.

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

    Nr\   r]   r>   r2   r   r     r`   r>   r   c                      e Zd ZdZy)r	   zGeneric warning for experimental features.

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

    Nr\   r]   r>   r2   r	   r	     r`   r>   r	   c                      e Zd ZdZy)r   zWarning raised when there are still open files at program exit.

    PyTables will close remaining open files at exit, but raise this warning.
    Nr\   r]   r>   r2   r   r     s    
 	r>   r   c                      e Zd ZdZy)r   zAn operation related to direct chunk access failed.

    This exception may be related with the properties of the dataset or the
    chunk being accessed, or with how the chunk is being accessed.  It is a
    base for more specific exceptions.

    Nr\   r]   r>   r2   r   r     rf   r>   r   c                      e Zd ZdZy)r   zA direct chunking operation was attempted on a non-chunked dataset.

    For instance, chunk information was requested for a plain ``Array``
    instance.

    Nr\   r]   r>   r2   r   r     r`   r>   r   c                      e Zd ZdZy)r   zCoordinate not aligned to the chunks.

    A direct chunk read/write operation was given coordinates that do not
    match the chunk's start.

    These operations require coordinates that are integer multiples of the
    dataset's chunksize.

    Nr\   r]   r>   r2   r   r     rb   r>   r   c                      e Zd ZdZy)r   a  The chunk with the given coordinates does not exist in storage.

    The coordinates are within the dataset's shape, though.

    This is only an error when the chunk is to be read.  Such a missing chunk
    can be written, in which case it is created in storage.

    Nr\   r]   r>   r2   r   r     s     	r>   r   )&rW   
__future__r   r&   r+   rO   collections.abcr   __all____docformat__RuntimeErrorr   r3   
ValueErrorr   r   r
   AttributeErrorLookupErrorr   r   	Exceptionr   Warningr   r   r   r   r   r   r   r   r	   r   r   r   r   r   r]   r>   r2   <module>r      s7   D " 	   $2 # 9p=< p=h      "	j 		j 		J 		 	(	i 			I 			g 			 				 				* 			G 			W 				g 			g 		 		' 			 			j 		: 	
	z 
	r>   