
    d                        d Z ddlZddlZddlZddlmZ dZ	  ej        d          Z	  ej        d          Z		  ej        d          Z
	  ej        d	          Z	 d
Z	 d Zd Zd Zd Zd Zd Zd Zedk    r e             dS dS )zFunctionality related with node paths in a PyTables file.

Variables
=========

`__docformat`__
    The format of documentation strings in this module.

    N   )NaturalNameWarningreStructuredTextz^[a-zA-Z_][a-zA-Z0-9_]*$z	^_[cfgv]_z^_[pi]_z/_[pi]_zmyou will not be able to use natural naming to access this object; using ``getattr()`` will still work, thoughc                 6   t          | t                    st          d|           | dk    rt          d          t                              |           s6t          j        d| dt          j        dt          t          d           d	S t          j        |           r)t          j        d
| dt          t          d           d	S t                              |           r t          d| dt          j        d          | dk    rt          d          d	S )a  Check the validity of the `name` of an attribute in AttributeSet.

    If the name is not valid, a ``ValueError`` is raised.  If it is
    valid but it can not be used with natural naming, a
    `NaturalNameWarning` is issued.

    >>> warnings.simplefilter("ignore")
    >>> check_attribute_name('a')
    >>> check_attribute_name('a_b')
    >>> check_attribute_name('a:b')         # NaturalNameWarning
    >>> check_attribute_name('/a/b')        # NaturalNameWarning
    >>> check_attribute_name('/')           # NaturalNameWarning
    >>> check_attribute_name('.')           # NaturalNameWarning
    >>> check_attribute_name('__members__')
    Traceback (most recent call last):
     ...
    ValueError: ``__members__`` is not allowed as an object name
    >>> check_attribute_name(1)
    Traceback (most recent call last):
     ...
    TypeError: object name is not a string: 1
    >>> check_attribute_name('')
    Traceback (most recent call last):
     ...
    ValueError: the empty string is not allowed as an object name
    zobject name is not a string:  z1the empty string is not allowed as an object namez.object name is not a valid Python identifier: z"; it does not match the pattern ``z``;    )
stacklevelNz!object name is a Python keyword: z; z+object name starts with a reserved prefix: z; it matches the pattern ``z``__members__z0``__members__`` is not allowed as an object name)
isinstancestr	TypeError
ValueError_python_id_rematchwarningswarnpattern	_warnInfor   keyword	iskeyword_reserved_id_renames    +lib/python3.11/site-packages/tables/path.pycheck_attribute_namer   5   sX   6 dC   B@@@AAArzzLMMM t$$ }444iiA )Q	8 	8 	8 	8 	  yy*+=!	M 	M 	M 	M T"" <j DD/"9"9"9; < < 	<
 }KLLL     c                 z    t          |            | dk    rt          d          d| v rt          d| z            dS )am  Check the validity of the `name` of a Node object, which more limited
    than attribute names.

    If the name is not valid, a ``ValueError`` is raised.  If it is
    valid but it can not be used with natural naming, a
    `NaturalNameWarning` is issued.

    >>> warnings.simplefilter("ignore")
    >>> check_name_validity('a')
    >>> check_name_validity('a_b')
    >>> check_name_validity('a:b')          # NaturalNameWarning
    >>> check_name_validity('/a/b')
    Traceback (most recent call last):
     ...
    ValueError: the ``/`` character is not allowed in object names: '/a/b'
    >>> check_name_validity('.')
    Traceback (most recent call last):
     ...
    ValueError: ``.`` is not allowed as an object name
    >>> check_name_validity('')
    Traceback (most recent call last):
     ...
    ValueError: the empty string is not allowed as an object name

    .z&``.`` is not allowed as an object name/z6the ``/`` character is not allowed in object names: %rN)r   r   r   s    r   check_name_validityr    o   s[    4  s{{ABBB	 /156 7 7 	7 
r   c                    |                     d          r
|dd         }| dk    r|                     d          rd|z  }n)| dk    s|                     d          r|  | }n|  d| }|                    d          r
|dd         }|S )ab  Join a *canonical* `parentpath` with a *non-empty* `name`.

    .. versionchanged:: 3.0
       The *parentPath* parameter has been renamed into *parentpath*.

    >>> join_path('/', 'foo')
    '/foo'
    >>> join_path('/foo', 'bar')
    '/foo/bar'
    >>> join_path('/foo', '/foo2/bar')
    '/foo/foo2/bar'
    >>> join_path('/foo', '/')
    '/foo'

    z./r   Nr   z%s)
startswithendswith)
parentpathr   pstrs      r   	join_pathr'      s    " t ABBxST__S11d{	s		dooc22	$d$$%%t%%}}S CRCyKr   c                 r    |                      d          }| d|         }| |dz   d         }|dk    rd}||fS )zSplit a *canonical* `path` into a parent path and a node name.

    The result is returned as a tuple.  The parent path does not
    include a trailing slash.

    >>> split_path('/')
    ('/', '')
    >>> split_path('/foo/bar')
    ('/foo', 'bar')

    r   Nr   r   )rfind)path	lastslashppathr   s       r   
split_pathr-      sK     

3I)E	AD{{4=r   c                 :    t                               |           du S )z3Does this `name` make the named node a visible one?N)_hidden_name_rer   r   s    r   isvisiblenamer0      s       &&$..r   c                 :    t                               |           du S )z3Does this `path` make the named node a visible one?N)_hidden_path_research)r*   s    r   isvisiblepathr4      s     !!$''4//r   c                  6    ddl } |                                  dS )zRun ``doctest`` on this module.r   N)doctesttestmod)r6   s    r   _testr8      s#     NNNOOr   __main__)__doc__rer   r   
exceptionsr   __docformat__compiler   r   r/   r2   r   r   r    r'   r-   r0   r4   r8   __name__ r   r   <module>rA      sE    
			   * * * * * *" 9 
566 +"*[)) "*Y''
 "*Y''	6 
 O7M 7M 7Mt"7 "7 "7J  <  ./ / /0 0 0   z	EGGGGG r   