
l_Oc           @   s   d  Z  e Z d d l Z d d l Z d d l Z d d l Z e j d  d k rh e Z	 d d l
 m Z n e Z	 d d l m Z d d l m Z m Z m Z d d l m Z d	 Z d
 e f d     YZ d e f d     YZ d d
 g Z d S(   so   
This module contains implementations of IFilePath for zip files.

See the constructor for ZipArchive for use.
iNi   i   (   t   ZipFile(   t   ChunkingZipFile(   t	   IFilePatht   FilePatht   AbstractFilePath(   t
   implementst   /t   ZipPathc           B   s   e  Z d  Z e e  e Z d   Z d   Z d   Z	 d   Z
 d   Z d   Z d   Z d   Z d	   Z d
   Z d   Z d   Z d   Z d   Z d d  Z d   Z d   Z d   Z d   Z d   Z RS(   sF   
    I represent a file or directory contained within a zip file.
    c         C   s@   | |  _  | |  _ t j j | j j |  j j t   |  _ d S(   s   
        Don't construct me directly.  Use ZipArchive.child().

        @param archive: a ZipArchive instance.

        @param pathInArchive: a ZIP_PATH_SEP-separated string.
        N(	   t   archivet   pathInArchivet   ost   patht   joint   zipfilet   filenamet   splitt   ZIP_PATH_SEP(   t   selfR   R	   (    (    sH   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/zippath.pyt   __init__0   s    		c         C   s8   t  | t  s t St |  j |  j f | j | j f  S(   N(   t
   isinstanceR   t   NotImplementedt   cmpR   R	   (   R   t   other(    (    sH   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/zippath.pyt   __cmp__?   s    c         C   sZ   t  j j |  j j  g } | j |  j j t   t  j j	 |  } d | j
 d  f S(   Ns   ZipPath('%s')s   string-escape(   R
   R   t   abspathR   t   extendR	   R   R   t   sepR   t   encode(   R   t   partsR   (    (    sH   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/zippath.pyt   __repr__F   s    c         C   sH   |  j  j t  } t |  d k r+ |  j St |  j t j | d    S(   Ni   i(   R	   R   R   t   lenR   R   R   (   R   t   splitup(    (    sH   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/zippath.pyt   parentM   s    c         C   s"   t  |  j t j |  j | g   S(   s&  
        Return a new ZipPath representing a path in C{self.archive} which is
        a child of this path.

        @note: Requesting the C{".."} (or other special name) child will not
            cause L{InsecurePath} to be raised since these names do not have
            any special meaning inside a zip archive.  Be particularly
            careful with the C{path} attribute (if you absolutely must use
            it) as this means it may include special names with special
            meaning outside of the context of a zip archive.
        (   R   R   R   R   R	   (   R   R   (    (    sH   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/zippath.pyt   childT   s    c         C   s   |  j    j |  S(   N(   R    R!   (   R   R   (    (    sH   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/zippath.pyt   siblingc   s    c         C   s   |  j    p |  j   S(   N(   t   isdirt   isfile(   R   (    (    sH   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/zippath.pyt   existsh   s    c         C   s   |  j  |  j j k S(   N(   R	   R   t   childmap(   R   (    (    sH   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/zippath.pyR#   k   s    c         C   s   |  j  |  j j j k S(   N(   R	   R   R   t
   NameToInfo(   R   (    (    sH   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/zippath.pyR$   n   s    c         C   s   t  S(   N(   t   False(   R   (    (    sH   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/zippath.pyt   islinkq   s    c         C   sZ   |  j    rD |  j   r/ |  j j |  j j   St t j d   n t t j	 d   d  S(   Ns   Leaf zip entry listeds   Non-existent zip entry listed(
   R%   R#   R   R&   R	   t   keyst   OSErrort   errnot   ENOTDIRt   ENOENT(   R   (    (    sH   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/zippath.pyt   listdirt   s
    c         C   s   t  j j |  j  S(   sN   
        Return a value similar to that returned by os.path.splitext.
        (   R
   R   t   splitext(   R   (    (    sH   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/zippath.pyR0   ~   s    c         C   s   |  j  j t  d S(   Ni(   R	   R   R   (   R   (    (    sH   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/zippath.pyt   basename   s    c         C   s   |  j    j S(   N(   R    R   (   R   (    (    sH   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/zippath.pyt   dirname   s    t   rc         C   sK   t  r" |  j j j |  j d | S| |  j j _ |  j j j |  j  Sd  S(   Nt   mode(   t   _USE_ZIPFILER   R   t   openR	   R4   t   readfile(   R   R4   (    (    sH   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/zippath.pyR6      s    c         C   s   d  S(   N(    (   R   (    (    sH   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/zippath.pyt   changed   s    c         C   s   |  j  j j |  j j S(   sR   
        Retrieve this file's size.

        @return: file size, in bytes
        (   R   R   R'   R	   t	   file_size(   R   (    (    sH   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/zippath.pyt   getsize   s    c         C   s   |  j  j   S(   s   
        Retrieve this file's last access-time.  This is the same as the last access
        time for the archive.

        @return: a number of seconds since the epoch
        (   R   t   getAccessTime(   R   (    (    sH   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/zippath.pyR;      s    c         C   s$   t  j |  j j j |  j j d  S(   s   
        Retrieve this file's last modification time.  This is the time of
        modification recorded in the zipfile.

        @return: a number of seconds since the epoch.
        i    (   i    i    i    (   t   timet   mktimeR   R   R'   R	   t	   date_time(   R   (    (    sH   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/zippath.pyt   getModificationTime   s    c         C   s
   |  j    S(   s   
        Retrieve this file's last modification time.  This name is provided for
        compatibility, and returns the same value as getmtime.

        @return: a number of seconds since the epoch.
        (   R?   (   R   (    (    sH   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/zippath.pyt   getStatusChangeTime   s    (   t   __name__t
   __module__t   __doc__R   R   R   R   R   R   R   R    R!   R"   R%   R#   R$   R)   R/   R0   R1   R2   R6   R8   R:   R;   R?   R@   (    (    (    sH   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/zippath.pyR   '   s.   
											
	
						
	t
   ZipArchivec           B   s\   e  Z d  Z e d    Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d   Z RS(	   s]    I am a FilePath-like object which can wrap a zip archive as if it were a
    directory.
    c         C   s   |  S(   N(    (   R   (    (    sH   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/zippath.pyt   <lambda>   s    c         C   s   t  r t |  |  _ n t |  |  _ | |  _ d |  _ i  |  _ x |  j j   D] } | j t	  } xi t
 t |   D]U } | | } t	 j | |   } | |  j k r i  |  j | <n  d |  j | | <qz Wd } qR Wd S(   s   Create a ZipArchive, treating the archive at archivePathname as a zip file.

        @param archivePathname: a str, naming a path in the filesystem.
        t    i   N(   R5   R    R   R   R   R	   R&   t   namelistR   R   t   rangeR   R   (   R   t   archivePathnamet   namet   xR!   R    (    (    sH   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/zippath.pyR      s    			c         C   s   t  |  |  S(   s   
        Create a ZipPath pointing at a path within the archive.

        @param path: a str with no path separators in it, either '/' or the
        system path separator, if it's different.
        (   R   (   R   R   (    (    sH   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/zippath.pyR!      s    c         C   s   t  |  j j  j   S(   s@   
        Returns true if the underlying archive exists.
        (   R   R   R   R%   (   R   (    (    sH   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/zippath.pyR%      s    c         C   s   t  |  j j  j   S(   s=   
        Return the archive file's last access time.
        (   R   R   R   R;   (   R   (    (    sH   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/zippath.pyR;      s    c         C   s   t  |  j j  j   S(   s>   
        Return the archive file's modification time.
        (   R   R   R   R?   (   R   (    (    sH   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/zippath.pyR?      s    c         C   s   t  |  j j  j   S(   s?   
        Return the archive file's status change time.
        (   R   R   R   R@   (   R   (    (    sH   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/zippath.pyR@     s    c         C   s   d t  j j |  j  f S(   Ns   ZipArchive(%r)(   R
   R   R   (   R   (    (    sH   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/zippath.pyR     s    (   RA   RB   RC   t   propertyR   R   R!   R%   R;   R?   R@   R   (    (    (    sH   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/zippath.pyRD      s   							(   i   i   (   RC   t   typet   __metaclass__R
   R<   R,   t   syst   version_infot   TrueR5   R   R    R(   t   twisted.python.zipstreamR   t   twisted.python.filepathR   R   R   t   zope.interfaceR   R   R   RD   t   __all__(    (    (    sH   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/zippath.pyt   <module>	   s    G