;
Êâ"Ic            
   @   sì   d  Z  d d l Z d d l Z d d l Z d d l Z d d l Z d d g Z d d d d d	 f \ Z Z Z	 Z
 Z d d f \ Z Z d
 „  Z d „  Z d „  Z d „  Z d d d „ Z Gd „  d ƒ Z d „  Z e d k o e ƒ  n d S(   u‘   Functions that read and write gzipped files.

The user of the file doesn't have to worry about the compression,
but random access is not allowed.i    Nu   GzipFileu   openi   i   i   i   i   c             C   s   |  d k  o |  d 7}  n |  S(   uŠ   Return i as an unsigned integer, assuming it fits in 32 bits.
    If it's >= 2GB when viewed as a 32-bit unsigned int, return a long.
    i    i   i    l        (    (   u   i(    (    u!   /mit/python/lib/python3.0/gzip.pyu   U32   s    c             C   s   |  d @S(   u3   Return the low-order 32 bits, as a non-negative intl   ÿÿ (    (   u   i(    (    u!   /mit/python/lib/python3.0/gzip.pyu   LOWU32   s    c             C   s   |  j  t j d | ƒ ƒ d  S(   Nu   <L(   u   writeu   structu   pack(   u   outputu   value(    (    u!   /mit/python/lib/python3.0/gzip.pyu   write32u   s    c             C   s   t  j d |  j d ƒ ƒ d S(   Nu   <Ii   i    (   u   structu   unpacku   read(   u   input(    (    u!   /mit/python/lib/python3.0/gzip.pyu   read32#   s    u   rbi	   c             C   s   t  |  | | ƒ S(   uŸ   Shorthand for GzipFile(filename, mode, compresslevel).

    The filename argument is required; mode defaults to 'rb'
    and compresslevel defaults to 9.

    (   u   GzipFile(   u   filenameu   modeu   compresslevel(    (    u!   /mit/python/lib/python3.0/gzip.pyu   open&   s    c             B   s1  |  Ee  Z d  Z d  Z d" Z d  d  d d  d „ Z e d „  ƒ Z d „  Z	 d „  Z
 d „  Z d	 „  Z d
 „  Z d „  Z d d „ Z d „  Z d d „ Z d „  Z d „  Z d „  Z d „  Z e j d „ Z d „  Z d „  Z d „  Z d „  Z d d „ Z d d „ Z d d „ Z d „  Z  d „  Z! d „  Z" d  S(#   uˆ   The GzipFile class simulates most of the methods of a file object with
    the exception of the readinto() and truncate() methods.

    i
   i   i	   c             C   sÄ  | o d | k o | d 7} n | d k o$ t j | | p d ƒ } |  _ n | d k o' t | d ƒ o | j } q‡ d } n | d k o' t | d ƒ o | j } q» d } n | d d … d k o: t |  _ d |  _	 d	 |  _
 d |  _ | |  _ d
 |  _ n… | d d … d k p | d d … d k oB t |  _ |  j | ƒ t j | t j t j t j d ƒ |  _ n t d | d ƒ ‚ | |  _ d |  _ |  j t k o |  j ƒ  n d S(   uA  Constructor for the GzipFile class.

        At least one of fileobj and filename must be given a
        non-trivial value.

        The new class instance is based on fileobj, which can be a regular
        file, a StringIO object, or any other object which simulates a file.
        It defaults to None, in which case filename is opened to provide
        a file object.

        When fileobj is not None, the filename argument is only used to be
        included in the gzip file header, which may includes the original
        filename of the uncompressed file.  It defaults to the filename of
        fileobj, if discernible; otherwise, it defaults to the empty string,
        and in this case the original filename is not included in the header.

        The mode argument can be any of 'r', 'rb', 'a', 'ab', 'w', or 'wb',
        depending on whether the file will be read or written.  The default
        is the mode of fileobj if discernible; otherwise, the default is 'rb'.
        Be aware that only the 'rb', 'ab', and 'wb' values should be used
        for cross-platform portability.

        The compresslevel argument is an integer from 1 to 9 controlling the
        level of compression; 1 is fastest and produces the least compression,
        and 9 is slowest and produces the most compression.  The default is 9.

        u   bu   rbu   nameu    u   modei    i   u   rs    id   u   wu   au   Mode u    not supportedNT(   u   Noneu   builtinsu   openu	   myfileobju   hasattru   nameu   modeu   READu   Trueu   _new_memberu   extrabufu	   extrasizeu   min_readsizeu   WRITEu   _init_writeu   zlibu   compressobju   DEFLATEDu	   MAX_WBITSu   DEF_MEM_LEVELu   compressu   IOErroru   fileobju   offsetu   _write_gzip_header(   u   selfu   filenameu   modeu   compresslevelu   fileobj(    (    u!   /mit/python/lib/python3.0/gzip.pyu   __init__8   s@     $ 
 
					.				c             C   sY   d d  l  } | j d t ƒ |  j t k o& |  j d d  … d k o |  j d S|  j S(   Ni    u   use the name attributeiýÿÿÿu   .gz(   u   warningsu   warnu   DeprecationWarningu   modeu   WRITEu   name(   u   selfu   warnings(    (    u!   /mit/python/lib/python3.0/gzip.pyu   filename~   s
    *c             C   s9   t  |  j ƒ } d | d d … d t t |  ƒ ƒ d S(   Nu   <gzip i   iÿÿÿÿu    u   >(   u   repru   fileobju   hexu   id(   u   selfu   s(    (    u!   /mit/python/lib/python3.0/gzip.pyu   __repr__†   s    c             C   s>   | |  _  t j d ƒ d @|  _ d |  _ g  |  _ d |  _ d  S(   Nu    l   ÿÿ i    (   u   nameu   zlibu   crc32u   crcu   sizeu   writebufu   bufsize(   u   selfu   filename(    (    u!   /mit/python/lib/python3.0/gzip.pyu   _init_writeŠ   s
    			c          
   C   s  |  j  j d ƒ |  j  j d ƒ y: |  j j d ƒ } | j d ƒ o | d  d … } n Wn t k
 o d } Yn Xd } | o
 t } n |  j  j t | ƒ j d ƒ ƒ t |  j  t	 t
 j
 ƒ  ƒ ƒ |  j  j d ƒ |  j  j d	 ƒ | o |  j  j | d
 ƒ n d  S(   Ns   ‹s   u   latin-1s   .gziýÿÿÿs    i    s   s   ÿs    (   u   fileobju   writeu   nameu   encodeu   endswithu   UnicodeEncodeErroru   FNAMEu   chru   write32uu   intu   time(   u   selfu   fnameu   flags(    (    u!   /mit/python/lib/python3.0/gzip.pyu   _write_gzip_header‘   s"    
c             C   s#   t  j d ƒ d @|  _ d |  _ d  S(   Nu    l   ÿÿ i    (   u   zlibu   crc32u   crcu   size(   u   self(    (    u!   /mit/python/lib/python3.0/gzip.pyu
   _init_read¦   s    c             C   sˆ  |  j  j d ƒ } | d k o t d ƒ ‚ n t |  j  j d ƒ ƒ } | d k o t d ƒ ‚ n t |  j  j d ƒ ƒ } |  j  j d ƒ | t @oL t |  j  j d ƒ ƒ } | d t |  j  j d ƒ ƒ } |  j  j | ƒ n | t @o6 x3 |  j  j d ƒ } | p | d	 k o Pqñ qñ n | t @o6 x3 |  j  j d ƒ } | p | d	 k o Pq2q2n | t @o |  j  j d ƒ n d  S(
   Ni   s   ‹u   Not a gzipped filei   i   u   Unknown compression methodi   i   s    (   u   fileobju   readu   IOErroru   ordu   FEXTRAu   FNAMEu   FCOMMENTu   FHCRC(   u   selfu   magicu   methodu   flagu   xlenu   s(    (    u!   /mit/python/lib/python3.0/gzip.pyu   _read_gzip_headerª   s0     c             C   sÐ   |  j  t k o" d d  l } t | j d ƒ ‚ n |  j d  k o t d ƒ ‚ n t | ƒ d k og |  j	 t | ƒ |  _	 t
 j | |  j ƒ d @|  _ |  j j |  j j | ƒ ƒ |  j t | ƒ 7_ n d  S(   Ni    u$   write() on read-only GzipFile objectu!   write() on closed GzipFile objectl   ÿÿ (   u   modeu   WRITEu   errnou   IOErroru   EBADFu   fileobju   Noneu
   ValueErroru   lenu   sizeu   zlibu   crc32u   crcu   writeu   compressu   offset(   u   selfu   datau   errno(    (    u!   /mit/python/lib/python3.0/gzip.pyu   writeÌ   s    iÿÿÿÿc             C   sz  |  j  t k o" d d  l } t | j d ƒ ‚ n |  j d k o |  j d  k o d Sd } | d k  oQ y- x& |  j | ƒ t	 |  j
 | d ƒ } qp Wq.t k
 o |  j } Yq.Xnt y? x8 | |  j k o' |  j | ƒ t	 |  j
 | d ƒ } qÁ WWn1 t k
 o% | |  j k o |  j } n Yn X|  j d  | … } |  j | d  … |  _ |  j | |  _ |  j | 7_ | S(   Ni    u$   read() on write-only GzipFile objects    i   i   (   u   modeu   READu   errnou   IOErroru   EBADFu	   extrasizeu   fileobju   Noneu   _readu   minu   max_read_chunku   EOFErroru   extrabufu   offset(   u   selfu   sizeu   errnou   readsizeu   chunk(    (    u!   /mit/python/lib/python3.0/gzip.pyu   readÙ   s4      c             C   s?   | |  j  |  _  t | ƒ |  j |  _ |  j t | ƒ 8_ d  S(   N(   u   extrabufu   lenu	   extrasizeu   offset(   u   selfu   buf(    (    u!   /mit/python/lib/python3.0/gzip.pyu   _unreadù   s    c             C   s  |  j  d  k o t d ƒ ‚ n |  j o |  j  j ƒ  } |  j  j d d ƒ | |  j  j ƒ  k o t d ƒ ‚ n |  j  j | ƒ |  j ƒ  |  j ƒ  t j	 t j
 ƒ |  _ d |  _ n |  j  j | ƒ } | d k o6 |  j j ƒ  } |  j ƒ  |  j | ƒ t d ƒ ‚ n |  j j | ƒ } |  j | ƒ |  j j d k o; |  j  j t |  j j ƒ d d ƒ |  j ƒ  d |  _ n d  S(	   Nu   Reached EOFi    i   s    i   i   FT(   u   fileobju   Noneu   EOFErroru   _new_memberu   tellu   seeku
   _init_readu   _read_gzip_headeru   zlibu   decompressobju	   MAX_WBITSu
   decompressu   Falseu   readu   flushu	   _read_eofu   _add_read_datau   unused_datau   lenu   True(   u   selfu   sizeu   posu   bufu
   uncompress(    (    u!   /mit/python/lib/python3.0/gzip.pyu   _readþ   s0    



$
c             C   s\   t  j | |  j ƒ d @|  _ |  j | |  _ |  j t | ƒ |  _ |  j t | ƒ |  _ d  S(   Nl   ÿÿ (   u   zlibu   crc32u   crcu   extrabufu	   extrasizeu   lenu   size(   u   selfu   data(    (    u!   /mit/python/lib/python3.0/gzip.pyu   _add_read_data0  s    c             C   s’   |  j  j d d ƒ t |  j  ƒ } t |  j  ƒ } | |  j k o) t d t | ƒ t |  j ƒ f ƒ ‚ n% | |  j d @k o t d ƒ ‚ n d  S(   Niøÿÿÿi   u   CRC check failed %s != %sl   ÿÿ u!   Incorrect length of data produced(   u   fileobju   seeku   read32u   crcu   IOErroru   hexu   size(   u   selfu   crc32u   isize(    (    u!   /mit/python/lib/python3.0/gzip.pyu	   _read_eof6  s    c             C   sº   |  j  d  k o d  S|  j t k oP |  j  j |  j j ƒ  ƒ t |  j  |  j ƒ t |  j  |  j	 d @ƒ d  |  _  n |  j t
 k o d  |  _  n |  j o |  j j ƒ  d  |  _ n d  S(   Nl   ÿÿ (   u   fileobju   Noneu   modeu   WRITEu   writeu   compressu   flushu   write32uu   crcu   sizeu   READu	   myfileobju   close(   u   self(    (    u!   /mit/python/lib/python3.0/gzip.pyu   closeE  s    
c             C   sR   y) |  j  d  k o |  j d  k o d  SWn t k
 o d  SYn X|  j ƒ  d  S(   N(   u	   myfileobju   Noneu   fileobju   AttributeErroru   close(   u   self(    (    u!   /mit/python/lib/python3.0/gzip.pyu   __del__T  s    	
c             C   sA   |  j  t k o  |  j j |  j j | ƒ ƒ n |  j j ƒ  d  S(   N(   u   modeu   WRITEu   fileobju   writeu   compressu   flush(   u   selfu	   zlib_mode(    (    u!   /mit/python/lib/python3.0/gzip.pyu   flush]  s     c             C   s   |  j  j ƒ  S(   u¥   Invoke the underlying file object's fileno() method.

        This will raise AttributeError if the underlying file object
        doesn't support fileno().
        (   u   fileobju   fileno(   u   self(    (    u!   /mit/python/lib/python3.0/gzip.pyu   filenoc  s    c             C   s   d S(   NF(   u   False(   u   self(    (    u!   /mit/python/lib/python3.0/gzip.pyu   isattyk  s    c             C   s   |  j  S(   N(   u   offset(   u   self(    (    u!   /mit/python/lib/python3.0/gzip.pyu   telln  s    c             C   sX   |  j  t k o t d ƒ ‚ n |  j j d ƒ d |  _ d |  _ d |  _ d |  _	 d S(   u[   Return the uncompressed stream file position indicator to the
        beginning of the fileu   Can't rewind in write modei    s    NT(
   u   modeu   READu   IOErroru   fileobju   seeku   Trueu   _new_memberu   extrabufu	   extrasizeu   offset(   u   self(    (    u!   /mit/python/lib/python3.0/gzip.pyu   rewindq  s    			i    c             C   s=  | o. | d k o |  j  | } q5 t d ƒ ‚ n |  j t k o| | |  j  k  o t d ƒ ‚ n | |  j  } t d ƒ } x% t | d ƒ D] } |  j | ƒ q W|  j t | d ƒ ƒ ny |  j t k oh | |  j  k  o |  j	 ƒ  n | |  j  } x% t | d ƒ D] } |  j
 d ƒ qW|  j
 | d ƒ n d  S(   Ni   u   Seek from end not supportedu   Negative seek in write modei   (   u   offsetu
   ValueErroru   modeu   WRITEu   IOErroru   bytesu   rangeu   writeu   READu   rewindu   read(   u   selfu   offsetu   whenceu   countu   chunku   i(    (    u!   /mit/python/lib/python3.0/gzip.pyu   seek|  s*      c             C   s_  | d k  o t  j } |  j } n | } g  } xð | d k oâ |  j | ƒ } | j d ƒ } | | k p  | d k o! t | ƒ | k o | d } n | d k p | d k o; | j | d  | d … ƒ |  j | | d d  … ƒ Pn | j | ƒ | t | ƒ } t | | d ƒ } q2 W| |  j k o  t | |  j d d ƒ |  _ n d j	 | ƒ S(   Ni    s   
iÿÿÿÿi   s    i   i   (
   u   sysu   maxsizeu   min_readsizeu   readu   findu   lenu   appendu   _unreadu   minu   join(   u   selfu   sizeu   readsizeu   bufsu   cu   i(    (    u!   /mit/python/lib/python3.0/gzip.pyu   readline“  s*    	 - c             C   st   | d k o t  j } n g  } xM | d k o? |  j ƒ  } | d k o Pn | j | ƒ | t | ƒ } q# W| S(   Ni    s    (   u   sysu   maxsizeu   readlineu   appendu   len(   u   selfu   sizehintu   Lu   line(    (    u!   /mit/python/lib/python3.0/gzip.pyu	   readlines²  s     c             C   s"   x | D] } |  j  | ƒ q Wd  S(   N(   u   write(   u   selfu   Lu   line(    (    u!   /mit/python/lib/python3.0/gzip.pyu
   writelinesÀ  s     c             C   s   |  S(   N(    (   u   self(    (    u!   /mit/python/lib/python3.0/gzip.pyu   __iter__Ä  s    c             C   s"   |  j  ƒ  } | o | St ‚ d  S(   N(   u   readlineu   StopIteration(   u   selfu   line(    (    u!   /mit/python/lib/python3.0/gzip.pyu   __next__Ç  s    Ni (  i    (#   u   __name__u
   __module__u   __doc__u   Noneu	   myfileobju   max_read_chunku   __init__u   propertyu   filenameu   __repr__u   _init_writeu   _write_gzip_headeru
   _init_readu   _read_gzip_headeru   writeu   readu   _unreadu   _readu   _add_read_datau	   _read_eofu   closeu   __del__u   zlibu   Z_SYNC_FLUSHu   flushu   filenou   isattyu   tellu   rewindu   seeku   readlineu	   readlinesu
   writelinesu   __iter__u   __next__(   u
   __locals__(    (    u!   /mit/python/lib/python3.0/gzip.pyu   GzipFile/   s<   
E					"	 	2											c              C   sÔ  t  j d d  … }  |  o |  d d k } | o |  d d  … }  n |  p d g }  n xt|  D]l} | o˜ | d k o+ t d d d d d	 t  j ƒ } t  j } qb| d
 d  … d k o t d t | ƒ ƒ q` n t | d ƒ } t j | d  d
 … d ƒ } n^ | d k o+ t  j } t d d d d d	 t  j ƒ } n& t j | d ƒ } t | d d ƒ } x+ | j	 d ƒ } | p Pn | j
 | ƒ qe| t  j k	 o | j ƒ  n | t  j k	 o | j ƒ  q` q` Wd  S(   Ni   i    u   -du   -u   filenameu    u   modeu   rbu   fileobjiýÿÿÿu   .gzu   filename doesn't end in .gz:u   wbi   (   u   sysu   argvu   GzipFileu   stdinu   stdoutu   printu   repru   openu   builtinsu   readu   writeu   close(   u   argsu
   decompressu   argu   fu   gu   chunk(    (    u!   /mit/python/lib/python3.0/gzip.pyu   _testÏ  s>      	"u   __main__(   u   __doc__u   structu   sysu   timeu   zlibu   builtinsu   __all__u   FTEXTu   FHCRCu   FEXTRAu   FNAMEu   FCOMMENTu   READu   WRITEu   U32u   LOWU32u   write32uu   read32u   openu   GzipFileu   _testu   __name__(    (    (    u!   /mit/python/lib/python3.0/gzip.pyu   <module>   s    $$					ÿ ¡	&