a
    =Â×_î+  ã                   @   s.  d Z dZddlZddlZddlZG dd„ deƒZe ¡  G dd„ deƒZ	G dd	„ d	eƒZ
G d
d„ deƒZG dd„ deeƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG d d!„ d!eƒZG d"d#„ d#eƒZdS )$z>Declare exceptions and warnings that are specific to PyTables.ZreStructuredTexté    Nc                       sJ   e Zd ZdZdZdZedd„ ƒZ‡ fdd„Z‡ fdd	„Z	dd
d„Z
‡  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                 C   sb   dddddddœ}| j }tj dd¡}z|| ¡  }W n  tyV   t d| ¡ Y n0 || _ |S )NFTr   )ZIGNOREZFALSEZSAVEZTRUEr   ÚDEFAULTZPT_DEFAULT_H5_BACKTRACE_POLICYr   z™Invalid 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)ÚclsZenvmapZoldvalueZenvvalueZnewvalue© r   ú0lib/python3.9/site-packages/tables/exceptions.pyÚset_policy_from_envW   s"    úýz HDF5ExtError.set_policy_from_envc                    sF   t t| ƒj|Ž  | d| j¡| _| jr<| jd ur<|  ¡ | _nd | _d S )NZh5bt)Úsuperr   Ú__init__r   r   Ú_h5bt_policyÚ_dump_h5_backtraceÚh5backtrace)ÚselfÚargsZkargs©Ú	__class__r   r   r   o   s    
zHDF5ExtError.__init__c                    s¤   t | jdv ƒ}|r’| jr’d d|  ¡ dg¡}t| jƒdkrft| jd tƒrft	t
| ƒ ¡ }d||f }q | jd d rŒd|| jd d f }q |}nt	t
| ƒ ¡ }|S )	zÄReturns 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%s

%séÿÿÿÿ)Úboolr   r   ÚjoinÚformat_h5_backtraceÚlenr   Ú
isinstanceÚstrr   r   Ú__str__)r   r   ZbtÚmsgr   r   r   r$   ‘   s    

ýzHDF5ExtError.__str__c                 C   s.   |du r| j }|du rdS d t |¡¡S dS )z£Convert 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   Z	backtracer   r   r   r    °   s
    z HDF5ExtError.format_h5_backtrace)N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   Úclassmethodr   r   r$   r    Ú__classcell__r   r   r   r   r      s   %
"r   c                   @   s   e Zd ZdZdS )ÚClosedNodeErrorzŽThe 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   r   r   r/   Ç   s   r/   c                   @   s   e Zd ZdZdS )ÚClosedFileErrorzŸThe operation can not be completed because the hosting file is closed.

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

    Nr0   r   r   r   r   r1   Ñ   s   r1   c                   @   s   e Zd ZdZdS )ÚFileModeErrorzË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.

    Nr0   r   r   r   r   r2   Ü   s   r2   c                   @   s   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.

    Nr0   r   r   r   r   r3   è   s   r3   c                   @   s   e Zd ZdZdS )ÚNoSuchNodeErrorz¿An 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.

    Nr0   r   r   r   r   r4   ü   s   r4   c                   @   s   e Zd ZdZdS )ÚUndoRedoErrorzúProblems 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.

    Nr0   r   r   r   r   r5     s   r5   c                   @   s   e Zd ZdZdS )ÚUndoRedoWarningz…Issued when an action not supporting Undo/Redo is run.

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

    Nr0   r   r   r   r   r6     s   r6   c                   @   s   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).
    Nr0   r   r   r   r   r7     s   r7   c                   @   s   e Zd ZdZdS )ÚPerformanceWarningzîWarning 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).

    Nr0   r   r   r   r   r8   )  s   r8   c                   @   s   e Zd ZdZdS )ÚFlavorErrorzûUnsupported 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.

    Nr0   r   r   r   r   r9   5  s   r9   c                   @   s   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.

    Nr0   r   r   r   r   r:   A  s   r:   c                   @   s   e Zd ZdZdS )ÚFiltersWarningzËUnavailable 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.

    Nr0   r   r   r   r   r;   P  s   r;   c                   @   s   e Zd ZdZdS )ÚOldIndexWarningz¾Unsupported 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.

    Nr0   r   r   r   r   r<   \  s   r<   c                   @   s   e Zd ZdZdS )ÚDataTypeWarningz¤Unsupported data type.

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

    Nr0   r   r   r   r   r=   h  s   r=   c                   @   s   e Zd ZdZdS )ÚExperimentalFeatureWarningz¬Generic warning for experimental features.

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

    Nr0   r   r   r   r   r>   s  s   r>   )r,   Z__docformat__r   r   r'   ÚRuntimeErrorr   r   Ú
ValueErrorr/   r1   r2   ÚAttributeErrorÚLookupErrorr3   r4   Ú	Exceptionr5   ÚWarningr6   r7   r8   r9   r:   r;   r<   r=   r>   r   r   r   r   Ú<module>   s,    *

