
    Kgg                     Z   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eddfdZdeddfdZdededefdZdedeeffdZdedefdZdedefdZddZedk(  r e        yy)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, thoughnamereturnc                    t        | t              st        d|       | dk(  rt        d      t        j                  |       s8t        j                  d| dt        j                  dt        t        d       y	t        j                  |       r't        j                  d
| dt         t        d       y	t        j                  |       r t        d| dt        j                  d      | dk(  rt        d      y	)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
_warn_infor   keyword	iskeyword_reserved_id_rer   s    +lib/python3.12/site-packages/tables/path.pycheck_attribute_namer   6   s    6 dC 7x@AArzLMM t$ ]**J8 	
 	 /xr*F	

 	 T"/3_5L5LN
 	
 }KLL     c                 ^    t        |        | dk(  rt        d      d| v rt        d| z        y)a  Check the validity of the `name` of a Node object.

    Validity of Node names is 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!   w   sB    6  s{ABB	G$N
 	
 
r   
parentpathc                     |j                  d      r|dd }| dk(  r|j                  d      rd|z  }n$| dk(  s|j                  d      r|  | }n|  d| }|j                  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)r"   r   pstrs      r   	join_pathr(      s      tABxST__S1d{	s	dooc2dV$Qtf%}}SCRyKr   pathc                 T    | j                  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)r)   	lastslashppathr   s       r   
split_pathr.      sC     

3I)E	A D{4=r   c                 0    t         j                  |       du S )z6Return `True` if  `name` makes the named node visible.N)_hidden_name_rer   r   s    r   isvisiblenamer1      s      &$..r   c                 0    t         j                  |       du S )z5Return `True` if `path` makes the named node visible.N)_hidden_path_research)r)   s    r   isvisiblepathr5      s    !!$'4//r   c                  ,    ddl } | j                          y)zRun ``doctest`` on this module.r   N)doctesttestmod)r7   s    r   _testr9      s    OOr   __main__)r   N)__doc__rer   r   
exceptionsr   __docformat__compiler   r   r0   r3   r   r   r   r!   r(   r.   boolr1   r5   r9   __name__ r   r   <module>rC      s$   
   *" 9 

56 +"**[) "**Y'
 "**Y'2  O>Ms >Mt >MB$
c $
d $
N# S S :S c3Z ,/ / /
0 0 0
 z	G r   