ó
$“‹]c           @   s“   d  d l  m Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z e	 Z
 d „  Z d „  Z d d d „  ƒ  YZ d S(   iÿÿÿÿ(   t   divisionNc         C   s   t  j t |  ƒ d d ƒ S(   s2  
    Given a path with elements separated by
    posixpath.sep, generate all parents of that path.

    >>> list(_parents('b/d'))
    ['b']
    >>> list(_parents('/b/d/'))
    ['/b']
    >>> list(_parents('b/d/f/'))
    ['b/d', 'b']
    >>> list(_parents('b'))
    []
    >>> list(_parents(''))
    []
    i   N(   t	   itertoolst   islicet	   _ancestryt   None(   t   path(    (    s#   lib/python2.7/site-packages/zipp.pyt   _parents   s    c         c   sL   |  j  t j ƒ }  x3 |  rG |  t j k rG |  Vt j |  ƒ \ }  } q Wd S(   sR  
    Given a path with elements separated by
    posixpath.sep, generate all elements of that path

    >>> list(_ancestry('b/d'))
    ['b/d', 'b']
    >>> list(_ancestry('/b/d/'))
    ['/b/d', '/b']
    >>> list(_ancestry('b/d/f/'))
    ['b/d/f', 'b/d', 'b']
    >>> list(_ancestry('b'))
    ['b']
    >>> list(_ancestry(''))
    []
    N(   t   rstript	   posixpatht   sept   split(   R   t   tail(    (    s#   lib/python2.7/site-packages/zipp.pyR   $   s    t   Pathc           B   s  e  Z d  Z d Z d d „ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z	 d „  Z
 d „  Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z e Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z d „  Z e j d k  re Z n  RS(   sš  
    A pathlib-compatible interface for zip files.

    Consider a zip file with this structure::

        .
        â”œâ”€â”€ a.txt
        â””â”€â”€ b
            â”œâ”€â”€ c.txt
            â””â”€â”€ d
                â””â”€â”€ e.txt

    >>> data = io.BytesIO()
    >>> zf = zipfile.ZipFile(data, 'w')
    >>> zf.writestr('a.txt', 'content of a')
    >>> zf.writestr('b/c.txt', 'content of c')
    >>> zf.writestr('b/d/e.txt', 'content of e')
    >>> zf.filename = 'abcde.zip'

    Path accepts the zipfile object itself or a filename

    >>> root = Path(zf)

    From there, several path operations are available.

    Directory iteration (including the zip file itself):

    >>> a, b = root.iterdir()
    >>> a
    Path('abcde.zip', 'a.txt')
    >>> b
    Path('abcde.zip', 'b/')

    name property:

    >>> b.name
    'b'

    join with divide operator:

    >>> c = b / 'c.txt'
    >>> c
    Path('abcde.zip', 'b/c.txt')
    >>> c.name
    'c.txt'

    Read text:

    >>> c.read_text()
    'content of c'

    existence:

    >>> c.exists()
    True
    >>> (b / 'missing.txt').exists()
    False

    Coercion to string:

    >>> str(c)
    'abcde.zip/b/c.txt'
    s>   {self.__class__.__name__}({self.root.filename!r}, {self.at!r})t    c         C   s@   t  | t j ƒ r | n t j |  j | ƒ ƒ |  _ | |  _ d  S(   N(   t
   isinstancet   zipfilet   ZipFilet   _pathlib_compatt   roott   at(   t   selfR   R   (    (    s#   lib/python2.7/site-packages/zipp.pyt   __init__}   s    c         C   s-   y |  j  ƒ  SWn t k
 r( t |  ƒ SXd S(   su   
        For path-like objects, convert to a filename for compatibility
        on Python 3.6.1 and earlier.
        N(   t
   __fspath__t   AttributeErrort   str(   R   (    (    s#   lib/python2.7/site-packages/zipp.pyR   …   s    c         C   s   t  j |  j j |  j ƒ S(   N(   t	   functoolst   partialR   t   openR   (   R   (    (    s#   lib/python2.7/site-packages/zipp.pyR      s    c         C   s   t  j |  j j d ƒ ƒ S(   Nt   /(   R   t   basenameR   R   (   R   (    (    s#   lib/python2.7/site-packages/zipp.pyt   name”   s    c         O   s2   |  j  ƒ    } t j | | | Ž j ƒ  SWd  QXd  S(   N(   R   t   iot   TextIOWrappert   read(   R   t   argst   kwargst   strm(    (    s#   lib/python2.7/site-packages/zipp.pyt	   read_text˜   s    c         C   s#   |  j  ƒ   } | j ƒ  SWd  QXd  S(   N(   R   R!   (   R   R$   (    (    s#   lib/python2.7/site-packages/zipp.pyt
   read_bytesœ   s    c         C   s+   t  j | j j d ƒ ƒ |  j j d ƒ k S(   NR   (   R   t   dirnameR   R   (   R   R   (    (    s#   lib/python2.7/site-packages/zipp.pyt	   _is_child    s    c         C   s   t  |  j | ƒ S(   N(   R   R   (   R   R   (    (    s#   lib/python2.7/site-packages/zipp.pyt   _next£   s    c         C   s   |  j  p |  j  j d ƒ S(   NR   (   R   t   endswith(   R   (    (    s#   lib/python2.7/site-packages/zipp.pyt   is_dir¦   s    c         C   s   |  j  ƒ  S(   N(   R+   (   R   (    (    s#   lib/python2.7/site-packages/zipp.pyt   is_file©   s    c         C   s   |  j  |  j ƒ  k S(   N(   R   t   _names(   R   (    (    s#   lib/python2.7/site-packages/zipp.pyt   exists¬   s    c         C   sC   |  j  ƒ  s t d ƒ ‚ n  t |  j |  j ƒ  ƒ } t |  j | ƒ S(   Ns   Can't listdir a file(   R+   t
   ValueErrort   mapR)   R-   t   filterR(   (   R   t   subs(    (    s#   lib/python2.7/site-packages/zipp.pyt   iterdir¯   s    c         C   s   t  j |  j j |  j ƒ S(   N(   R   t   joinR   t   filenameR   (   R   (    (    s#   lib/python2.7/site-packages/zipp.pyt   __str__µ   s    c         C   s   |  j  j d |  ƒ S(   NR   (   t   _Path__reprt   format(   R   (    (    s#   lib/python2.7/site-packages/zipp.pyt   __repr__¸   s    c         C   ss   |  j  | ƒ } t j |  j | ƒ } t j |  j | d ƒ } |  j ƒ  } |  j | | k rl | | k rl | n | ƒ S(   NR   (   R   R   R4   R   R-   R)   (   R   t   addt   nextt   next_dirt   names(    (    s#   lib/python2.7/site-packages/zipp.pyt   joinpath»   s
    c            s   t  j ‡  f d †  ˆ  Dƒ ƒ S(   Nc         3   s<   |  ]2 } t  | ƒ D] } | d  ˆ  k r | d  Vq q d S(   R   N(   R   (   t   .0R   t   parent(   R=   (    s#   lib/python2.7/site-packages/zipp.pys	   <genexpr>Ç   s   (   t   more_itertoolst   unique_everseen(   R=   (    (   R=   s#   lib/python2.7/site-packages/zipp.pyt   _implied_dirsÄ   s    c         C   s   | t  |  j | ƒ ƒ S(   N(   t   listRC   (   t   clsR=   (    (    s#   lib/python2.7/site-packages/zipp.pyt   _add_implied_dirsÍ   s    c         C   s;   t  j |  j j d ƒ ƒ } | r. | d 7} n  |  j | ƒ S(   NR   (   R   R'   R   R   R)   (   R   t	   parent_at(    (    s#   lib/python2.7/site-packages/zipp.pyR@   Ñ   s    c         C   s   |  j  |  j j ƒ  ƒ S(   N(   RF   R   t   namelist(   R   (    (    s#   lib/python2.7/site-packages/zipp.pyR-   Ø   s    i   (   i   (   t   __name__t
   __module__t   __doc__R7   R   t   staticmethodR   t   propertyR   R   R%   R&   R(   R)   R+   R,   R.   R3   R6   R9   R>   t   __truediv__RC   t   classmethodRF   R@   R-   t   syst   version_infot   __div__(    (    (    s#   lib/python2.7/site-packages/zipp.pyR   :   s0   ?													(    (   t
   __future__R    R   RP   R   R   R   R   RA   t   typet   __metaclass__R   R   R   (    (    (    s#   lib/python2.7/site-packages/zipp.pyt   <module>   s   		