ó
jˆú\c           @@  s÷   d  Z  d d l m Z d d l Z d d l Z d d l Z d d l m Z d d l 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 ƒ  n  d S(   s™   Functionality related with node paths in a PyTables file.

Variables
=========

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

i    (   t   absolute_importNi   (   t   NaturalNameWarningt   reStructuredTexts   ^[a-zA-Z_][a-zA-Z0-9_]*$s	   ^_[cfgv]_s   ^_[pi]_s   /_[pi]_sm   you will not be able to use natural naming to access this object; using ``getattr()`` will still work, thoughc         C@  sù   t  |  t j ƒ s( t d |  f ƒ ‚ n  |  d k rC t d ƒ ‚ n  t j |  ƒ s| t j d |  t j	 t
 f t d d ƒd St j |  ƒ r¯ t j d |  t
 f t d d ƒd St j |  ƒ rÚ t d	 |  t j	 f ƒ ‚ n  |  d
 k rõ t d ƒ ‚ n  d S(   si  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.

    >>> check_attribute_name('a')
    >>> check_attribute_name('a_b')
    >>> check_attribute_name('a:b')
    >>> check_attribute_name('/a/b')
    >>> check_attribute_name('/')
    >>> check_attribute_name('.')
    >>> 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
    s   object name is not a string: %rt    s1   the empty string is not allowed as an object namesZ   object name is not a valid Python identifier: %r; it does not match the pattern ``%s``; %st
   stackleveli   Ns'   object name is a Python keyword: %r; %ssL   object name starts with a reserved prefix: %r; it matches the pattern ``%s``t   __members__s0   ``__members__`` is not allowed as an object name(   t
   isinstancet   sixt   string_typest	   TypeErrort
   ValueErrort   _python_id_ret   matcht   warningst   warnt   patternt	   _warnInfoR   t   keywordt	   iskeywordt   _reserved_id_re(   t   name(    (    s*   lib/python2.7/site-packages/tables/path.pyt   check_attribute_nameK   s$    		c         C@  sH   t  |  ƒ |  d k r% t d ƒ ‚ n d |  k rD t d |  ƒ ‚ n  d S(   s'  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.

    >>> check_name_validity('a')
    >>> check_name_validity('a_b')
    >>> check_name_validity('a:b')
    >>> 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

    t   .s&   ``.`` is not allowed as an object namet   /s6   the ``/`` character is not allowed in object names: %rN(   R   R
   (   R   (    (    s*   lib/python2.7/site-packages/tables/path.pyt   check_name_validity„   s    
c         C@  s¢   | j  d ƒ r | d } n  |  d k rD | j  d ƒ rD d | } n> |  d k s_ | j  d ƒ rr d |  | f } n d |  | f } | j d ƒ rž | d  } n  | S(   sb  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'

    s   ./i   R   s   %ss   %s%ss   %s/%siÿÿÿÿ(   t
   startswitht   endswith(   t
   parentpathR   t   pstr(    (    s*   lib/python2.7/site-packages/tables/path.pyt	   join_path¬   s    c         C@  sF   |  j  d ƒ } |  |  } |  | d } | d k r< d } n  | | f S(   sþ   Split 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   i   R   (   t   rfind(   t   patht	   lastslasht   ppathR   (    (    s*   lib/python2.7/site-packages/tables/path.pyt
   split_pathË   s    
	c         C@  s   t  j |  ƒ d k S(   s3   Does this `name` make the named node a visible one?N(   t   _hidden_name_reR   t   None(   R   (    (    s*   lib/python2.7/site-packages/tables/path.pyt   isvisiblenameã   s    c         C@  s   t  j |  ƒ d k S(   s3   Does this `path` make the named node a visible one?N(   t   _hidden_path_ret   searchR$   (   R   (    (    s*   lib/python2.7/site-packages/tables/path.pyt   isvisiblepathê   s    c          C@  s   d d l  }  |  j ƒ  d S(   s   Run ``doctest`` on this module.i    N(   t   doctestt   testmod(   R)   (    (    s*   lib/python2.7/site-packages/tables/path.pyt   _testó   s    t   __main__(   t   __doc__t
   __future__R    t   reR   R   t
   exceptionsR   R   t   __docformat__t   compileR   R   R#   R&   R   R   R   R   R"   R%   R(   R+   t   __name__(    (    (    s*   lib/python2.7/site-packages/tables/path.pyt   <module>   s*   			9	(						