ó
è¾bc           @   s?  d  Z  d g Z d d „ Z g  Z d „  Z e j e ƒ d „  Z e j e ƒ d „  Z e j e ƒ d „  Z	 e j e	 ƒ d „  Z
 e j e
 ƒ d „  Z e j e ƒ d	 „  Z e j e ƒ d
 „  Z e j e ƒ d „  Z e j e ƒ d „  Z e j e ƒ d „  Z e j e ƒ d „  Z e j e ƒ d „  Z d „  Z d S(   s<   Recognize image file formats based on their first few bytes.t   whatc         C   s¶   d  } z• | d  k rp t |  t ƒ rE t |  d ƒ } | j d ƒ } qp |  j ƒ  } |  j d ƒ } |  j | ƒ n  x' t D] } | | | ƒ } | rw | Sqw WWd  | r± | j ƒ  n  Xd  S(   Nt   rbi    (	   t   Nonet
   isinstancet
   basestringt   opent   readt   tellt   seekt   testst   close(   t   filet   ht   ft   locationt   tft   res(    (    s   /usr/lib/python2.7/imghdr.pyR    	   s      c         C   s   |  d d !d k r d Sd S(   s   JPEG data in JFIF formati   i
   t   JFIFt   jpegN(    (   R   R   (    (    s   /usr/lib/python2.7/imghdr.pyt	   test_jpeg#   s    c         C   s   |  d d !d k r d Sd S(   s   JPEG data in Exif formati   i
   t   ExifR   N(    (   R   R   (    (    s   /usr/lib/python2.7/imghdr.pyt	   test_exif*   s    c         C   s   |  d  d k r d Sd  S(   Ni   s   ‰PNG

t   png(    (   R   R   (    (    s   /usr/lib/python2.7/imghdr.pyt   test_png1   s    c         C   s   |  d  d k r d Sd S(   s   GIF ('87 and '89 variants)i   t   GIF87at   GIF89at   gifN(   R   R   (    (   R   R   (    (    s   /usr/lib/python2.7/imghdr.pyt   test_gif7   s    c         C   s   |  d  d k r d Sd S(   s-   TIFF (can be in Motorola or Intel byte order)i   t   MMt   IIt   tiffN(   R   R   (    (   R   R   (    (    s   /usr/lib/python2.7/imghdr.pyt	   test_tiff>   s    c         C   s   |  d  d k r d Sd S(   s   SGI image libraryi   s   Út   rgbN(    (   R   R   (    (    s   /usr/lib/python2.7/imghdr.pyt   test_rgbE   s    c         C   sJ   t  |  ƒ d k rF |  d d k rF |  d d k rF |  d d k rF d Sd	 S(
   s   PBM (portable bitmap)i   i    t   Pi   t   14i   s    	
t   pbmN(   t   len(   R   R   (    (    s   /usr/lib/python2.7/imghdr.pyt   test_pbmL   s    0c         C   sJ   t  |  ƒ d k rF |  d d k rF |  d d k rF |  d d k rF d Sd	 S(
   s   PGM (portable graymap)i   i    R"   i   t   25i   s    	
t   pgmN(   R%   (   R   R   (    (    s   /usr/lib/python2.7/imghdr.pyt   test_pgmT   s    0c         C   sJ   t  |  ƒ d k rF |  d d k rF |  d d k rF |  d d k rF d Sd	 S(
   s   PPM (portable pixmap)i   i    R"   i   t   36i   s    	
t   ppmN(   R%   (   R   R   (    (    s   /usr/lib/python2.7/imghdr.pyt   test_ppm\   s    0c         C   s   |  d  d k r d Sd S(   s   Sun raster filei   s   Y¦j•t   rastN(    (   R   R   (    (    s   /usr/lib/python2.7/imghdr.pyt	   test_rastd   s    c         C   s$   d } |  t  | ƒ  | k r  d Sd S(   s   X bitmap (X10 or X11)s   #define t   xbmN(   R%   (   R   R   t   s(    (    s   /usr/lib/python2.7/imghdr.pyt   test_xbmk   s    c         C   s   |  d  d k r d Sd  S(   Ni   t   BMt   bmp(    (   R   R   (    (    s   /usr/lib/python2.7/imghdr.pyt   test_bmps   s    c          C   s»   d d  l  }  d } |  j d rH |  j d d k rH |  j d d 5d } n  y> |  j d rr t |  j d | d ƒ n t d g | d ƒ Wn. t k
 r¶ |  j j d ƒ |  j d ƒ n Xd  S(   Niÿÿÿÿi    i   s   -ri   t   .s   
[Interrupted]
(   t   syst   argvt   testallt   KeyboardInterruptt   stderrt   writet   exit(   R6   t	   recursive(    (    s   /usr/lib/python2.7/imghdr.pyt   test}   s     	c         C   sÚ   d d  l  } d d  l } x» |  D]³ } | j j | ƒ r• | d G| sK | r d GHd d  l } | j | j j | d ƒ ƒ } t | | d ƒ qÒ d GHq | d G| j j ƒ  y t	 | ƒ GHWq t
 k
 rÑ d GHq Xq Wd  S(	   Niÿÿÿÿs   /:s   recursing down:t   *i    s   *** directory (use -r) ***t   :s   *** not found ***(   R6   t   ost   patht   isdirt   globt   joinR8   t   stdoutt   flushR    t   IOError(   t   listR=   t   toplevelR6   RA   t   filenameRD   t   names(    (    s   /usr/lib/python2.7/imghdr.pyR8   Œ   s"    N(   t   __doc__t   __all__R   R    R	   R   t   appendR   R   R   R   R!   R&   R)   R,   R.   R1   R4   R>   R8   (    (    (    s   /usr/lib/python2.7/imghdr.pyt   <module>   s:   														