Ñò
…n+Oc           @   sâ   d  d k  Z  d  d k Z d  d k Z d  d k Z d Z d Z h d d  6d d 6d d 6d	 d
 6d d 6Z d „  Z d „  Z d e  i  f d „  ƒ  YZ	 d e	 f d „  ƒ  YZ
 d d d „  ƒ  YZ d d d „  ƒ  YZ d „  Z d „  Z d S(   iÿÿÿÿNi   i   s   image buffer overrun errors   decoding erroriþÿÿÿs   unknown erroriýÿÿÿs   bad configurationiøÿÿÿs   out of memory errori÷ÿÿÿc         C   sd   y t  i i |  ƒ } Wn" t j
 o t i |  ƒ } n X| p d |  } n t | d ƒ ‚ d  S(   Ns   decoder error %ds    when reading image file(   t   Imaget   coret   getcodecstatust   AttributeErrort   ERRORSt   gett   IOError(   t   errort   message(    (    s7   /usr/local/lib/python2.6/dist-packages/PIL/ImageFile.pyt   raise_ioerror-   s    c         C   s   t  |  d | d ƒ S(   Ni   (   t   cmp(   t   t1t   t2(    (    s7   /usr/local/lib/python2.6/dist-packages/PIL/ImageFile.pyt	   _tilesort:   s    t	   ImageFilec           B   sJ   e  Z d  Z d d d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z	 RS(   s*   Base class for image file format handlers.c         C   s£  t  i  i |  ƒ d  |  _ d |  _ d |  _ t |  _ t  i | ƒ o t	 | d ƒ |  _
 | |  _ n | |  _
 | |  _ y |  i ƒ  Wní t j
 o0 } t  i d j o t i ƒ  n t | ‚ n³ t j
 o0 } t  i d j o t i ƒ  n t | ‚ nx t j
 o0 } t  i d j o t i ƒ  n t | ‚ n= t j
 o0 } t  i d j o t i ƒ  n t | ‚ n X|  i p |  i d d j o t d ‚ n d  S(   Ni   t   rbi    s   not identified by this driver(    (   R    t   __init__t   Nonet   tilet   readonlyt   decoderconfigt   MAXBLOCKt   decodermaxblockt   isStringTypet   opent   fpt   filenamet   _opent
   IndexErrort   DEBUGt	   tracebackt	   print_exct   SyntaxErrort	   TypeErrort   KeyErrort   EOFErrort   modet   size(   t   selfR   R   t   v(    (    s7   /usr/local/lib/python2.6/dist-packages/PIL/ImageFile.pyR   H   s<    						c         C   s   d S(   s   Set draft modeN(    (   R&   R$   R%   (    (    s7   /usr/local/lib/python2.6/dist-packages/PIL/ImageFile.pyt   draftp   s    c         C   s   d |  _ d S(   s   Check file integrityN(   R   R   (   R&   (    (    s7   /usr/local/lib/python2.6/dist-packages/PIL/ImageFile.pyt   verifyu   s    c         C   s.  t  i  i |  ƒ } |  i d j o t d ƒ ‚ n |  i p | Sd |  _ d } |  i ot |  i ƒ d j ok|  i d \ } } } } | d j oA| d |  i j o-| d t  i	 j oyí t
 t  i d ƒ oX t  i i |  i ƒ |  _ |  i i | ƒ |  i i |  i |  i | d | d ƒ |  _ ny d d k } t |  i d	 ƒ } t i i |  i ƒ }	 | i | i ƒ  |	 ƒ |  _ t  i i |  i |  i | | | | ƒ |  _ d } Wq×t t t f j
 o d |  _ q×XqÛn |  i ƒ  y |  i }
 Wn t j
 o |  i i }
 n Xy |  i } Wn t j
 o |  i i } n X|  i pK|  i i t  ƒ y |  i! } Wn t j
 o d
 } n Xx|  i D] \ } } } } t  i" |  i | | |  i# ƒ } | | ƒ y | i$ |  i | ƒ Wn t% j
 o
 qn X| } t | ƒ } x |
 |  i& ƒ } | p# g  |  _ t d t | ƒ ƒ ‚ n | | } | i' | ƒ \ } } | d j  o Pn | | } | | } qqWn g  |  _ | |  _( d |  _ |  i o | d j  o t) | ƒ n t
 |  d ƒ o+ |  i i* |  i+ ƒ |  _ |  i i |  _ n |  i, ƒ  t  i  i |  ƒ S(   s"   Load image data based on tile lists   cannot load this imagei    i   t   rawt   mapi   iÿÿÿÿNs   r+t    s0   image file is truncated (%d bytes not processed)t   tile_post_rotate(-   R    t   loadR   R   R   R+   R   t   lenR$   t	   _MAPMODESt   hasattrR   t   seekt	   readimageR%   t   imt   mmapR   t   ost   patht   getsizet   filenot
   map_bufferR   t   EnvironmentErrort   ImportErrort   load_preparet	   load_readR   t   readt	   load_seekt   sortR   t   tile_prefixt   _getdecoderR   t   setimaget
   ValueErrorR   t   decodeR   R	   t   rotateR-   t   load_end(   R&   t   pixelR   t   dt   et   ot   aR5   t   fileR%   R?   R2   t   prefixt   bt   tt   st   n(    (    s7   /usr/local/lib/python2.6/dist-packages/PIL/ImageFile.pyR.   |   sŽ    
	 5	'	!



 
	

			
c         C   s   |  i  p, |  i  i |  i j p |  i  i |  i j o" t i i |  i |  i ƒ |  _  n |  i d j o t i i |  ƒ n d  S(   Nt   P(   R4   R$   R%   R    R   t   newR.   (   R&   (    (    s7   /usr/local/lib/python2.6/dist-packages/PIL/ImageFile.pyR=   ã   s
    ,"c         C   s   d  S(   N(    (   R&   (    (    s7   /usr/local/lib/python2.6/dist-packages/PIL/ImageFile.pyRH   ì   s    N(
   t   __name__t
   __module__t   __doc__R   R   R(   R)   R.   R=   RH   (    (    (    s7   /usr/local/lib/python2.6/dist-packages/PIL/ImageFile.pyR   E   s   (			g		t   StubImageFilec           B   s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   s"   Base class for stub image loaders.c         C   s   t  d ƒ ‚ d  S(   Ns+   StubImageFile subclass must implement _open(   t   NotImplementedError(   R&   (    (    s7   /usr/local/lib/python2.6/dist-packages/PIL/ImageFile.pyR     s    c         C   so   |  i  ƒ  } | d  j o t d |  i ƒ ‚ n | i |  ƒ } | d  j	 p t ‚ | i |  _ | i |  _ d  S(   Ns#   cannot find loader for this %s file(   t   _loadR   R   t   formatR.   t   AssertionErrort	   __class__t   __dict__(   R&   t   loadert   image(    (    s7   /usr/local/lib/python2.6/dist-packages/PIL/ImageFile.pyR.     s    c         C   s   t  d ƒ ‚ d  S(   Ns+   StubImageFile subclass must implement _load(   RZ   (   R&   (    (    s7   /usr/local/lib/python2.6/dist-packages/PIL/ImageFile.pyR[     s    (   RV   RW   RX   R   R.   R[   (    (    (    s7   /usr/local/lib/python2.6/dist-packages/PIL/ImageFile.pyRY   þ   s   		t   _ParserFilec           B   sD   e  Z d  „  Z d „  Z d „  Z d d „ Z d d „ Z d „  Z RS(   c         C   s   | |  _  d |  _ d  S(   Ni    (   t   datat   offset(   R&   Rc   (    (    s7   /usr/local/lib/python2.6/dist-packages/PIL/ImageFile.pyR     s    	c         C   s   d  |  _ |  _ d  S(   N(   R   Rc   Rd   (   R&   (    (    s7   /usr/local/lib/python2.6/dist-packages/PIL/ImageFile.pyt   close"  s    c         C   s   |  i  S(   N(   Rd   (   R&   (    (    s7   /usr/local/lib/python2.6/dist-packages/PIL/ImageFile.pyt   tell%  s    i    c         C   sK   | d j o | |  _  n. | d j o |  i  | |  _  n t d ƒ ‚ d  S(   Ni    i   s   illegal argument to seek(   Rd   R   (   R&   Rd   t   whence(    (    s7   /usr/local/lib/python2.6/dist-packages/PIL/ImageFile.pyR2   (  s
    c         C   sL   |  i  } | o |  i | | | !} n |  i | } | t | ƒ |  _  | S(   N(   Rd   Rc   R/   (   R&   t   bytest   posRc   (    (    s7   /usr/local/lib/python2.6/dist-packages/PIL/ImageFile.pyR?   1  s    	c         C   sG   d } x: |  i  d ƒ } | p Pn | | } | d j o Pq	 q	 | S(   NR,   i   s   
(   R?   (   R&   RR   t   c(    (    s7   /usr/local/lib/python2.6/dist-packages/PIL/ImageFile.pyt   readline:  s    
(   RV   RW   R   Re   Rf   R2   R?   Rk   (    (    (    s7   /usr/local/lib/python2.6/dist-packages/PIL/ImageFile.pyRb     s   					t   Parserc           B   sA   e  Z d Z d Z d Z d Z d  Z d „  Z d „  Z	 d „  Z
 RS(   i    c         C   s   |  i  d  j p
 t d ‚ d  S(   Ns   cannot reuse parsers(   Rc   R   R]   (   R&   (    (    s7   /usr/local/lib/python2.6/dist-packages/PIL/ImageFile.pyt   resetW  s    c         C   s‚  |  i  o d  S|  i d  j o | |  _ n |  i | |  _ |  i oé |  i d j o_ t t |  i ƒ |  i ƒ } |  i | |  _ |  i | |  _ |  i d j p |  i o d  Sn |  i i |  i ƒ \ } } | d j  o> d  |  _ d |  _  | d j  o d  |  _ t	 | ƒ qd  Sn |  i | |  _ nP|  i o nBy4 z" t
 |  i ƒ } t i | ƒ } Wd  | i ƒ  XWn t j
 o nù Xt | d ƒ p t | d ƒ } | p t | i ƒ d j o d  |  _ n¦ | i ƒ  | i d \ } } }	 }
 g  | _ t i | i | |
 | i ƒ |  _ |  i i | i | ƒ |	 |  _ |  i t |  i ƒ j o  |  i |  i |  _ d |  _ n | |  _ d  S(   Ni    i   R@   R>   (   t   finishedRc   R   t   decoderRd   t   minR/   RF   Ra   R	   Rb   R    R   Re   R   R1   R   R=   RC   R$   R   RD   R4   (   R&   Rc   t   skipRS   RK   R   R4   t   flagRJ   RL   RM   (    (    s7   /usr/local/lib/python2.6/dist-packages/PIL/ImageFile.pyt   feed`  sX    

				

		c         C   s´   |  i  o; |  i d ƒ d  |  _ |  _  |  i p t d ƒ ‚ qE n |  i p t d ƒ ‚ n |  i oD z% t |  i ƒ } t i	 | ƒ |  _ Wd  |  i i
 ƒ  | i ƒ  Xn |  i S(   NR,   s   image was incompletes   cannot parse this image(   Ro   Rs   R   Rc   Rn   R   Ra   Rb   R    R   R.   Re   (   R&   R   (    (    s7   /usr/local/lib/python2.6/dist-packages/PIL/ImageFile.pyRe   ´  s    



N(   RV   RW   R   t   incrementalRa   Rc   Ro   Rn   Rm   Rs   Re   (    (    (    s7   /usr/local/lib/python2.6/dist-packages/PIL/ImageFile.pyRl   J  s   			Tc      	   C   s  |  i  ƒ  t |  d ƒ p d |  _ n | i t ƒ t t |  i d d ƒ } y | i ƒ  } | i	 ƒ  WnÚ t
 j
 oÎ xk| D]¼ \ } } } } t i |  i | | |  i ƒ } | d j o | i | d ƒ n | i |  i | ƒ x4 | i | ƒ \ }	 }
 } | i | ƒ |
 o Pqç qç |
 d j  o t d |
 ƒ ‚ q€ q€ Wn¤ XxŸ | D]— \ } } } } t i |  i | | |  i ƒ } | d j o | i | d ƒ n | i |  i | ƒ | i | | ƒ }
 |
 d j  o t d |
 ƒ ‚ qLqLWy | i	 ƒ  Wn n Xd S(   s'   Helper to save image based on tile listt   encoderconfigi    i   s(   encoder error %d when writing image fileN(    (   R.   R1   Ru   RA   R   t   maxR   R%   R9   t   flushR   R    t   _getencoderR$   R2   RD   R4   t   encodet   writeR   t   encode_to_file(   R4   R   R   t   bufsizet   fhRK   RP   RL   RM   t   lRR   RJ   (    (    s7   /usr/local/lib/python2.6/dist-packages/PIL/ImageFile.pyt   _saveÒ  sF    
   c         C   s™   | d j o d S| t  j o |  i | ƒ Sg  } xS | d j oE |  i t | t  ƒ ƒ } | p Pn | i | ƒ | t | ƒ } q6 Wt i | d ƒ S(   Ni    R,   (   t	   SAFEBLOCKR?   Rp   t   appendR/   t   stringt   join(   R   R%   Rc   t   block(    (    s7   /usr/local/lib/python2.6/dist-packages/PIL/ImageFile.pyt
   _safe_read  s     i   (    (    (   R    R   R‚   R6   R   R€   R   R	   R   R   RY   Rb   Rl   R   R…   (    (    (    s7   /usr/local/lib/python2.6/dist-packages/PIL/ImageFile.pyt   <module>   s"   $
		¹/ˆ	2