ó
È4ec           @  s2  d  d l  m Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l m Z e j j	 d k ru d  d l
 m Z n d  d l m Z g  Z d d „ Z d d „ Z d	 e f d
 „  ƒ  YZ e j d k rë d e f d „  ƒ  YZ e e ƒ nÞ e j d k rd e f d „  ƒ  YZ e e ƒ n¬ d „  Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ e d ƒ rke e ƒ n  d e f d „  ƒ  YZ e d ƒ rše e ƒ n  d e f d „  ƒ  YZ e d ƒ rÉe e ƒ n  e d k r.e e j ƒ d k  re d ƒ e j ƒ  n  e e e j  e j d ƒ e j d Œ ƒ n  d S(    iÿÿÿÿ(   t   print_functionN(   t   Imagei   (   t   quotei   c         C  sr   y t  |  t ƒ r |  ƒ  }  n  Wn t k
 r2 n X| d k rO t j |  ƒ n | d k  rn t j d |  ƒ n  d  S(   Ni    (   t
   issubclasst   Viewert	   TypeErrort   _viewerst   appendt   insert(   t   viewert   order(    (    s7   /usr/local/lib/python2.7/dist-packages/PIL/ImageShow.pyt   register    s    c         K  s1   x* t  D]" } | j |  d | | r d Sq Wd S(   s  
    Display a given image.

    :param image: An image object.
    :param title: Optional title.  Not all viewers can display the title.
    :param \**options: Additional viewer options.
    :returns: True if a suitable viewer was found, false otherwise.
    t   titlei   i    (   R   t   show(   t   imageR   t   optionsR	   (    (    s7   /usr/local/lib/python2.7/dist-packages/PIL/ImageShow.pyR   ,   s    	R   c           B  sP   e  Z d  Z d „  Z d Z i  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z RS(   s   Base class for viewers.c         K  ss   | j  d k p* |  j d k o* | j  d k sc t j | j  ƒ } | j  | k rc | j | ƒ } qc n  |  j | |  S(   Nt   1t   RGBAt   PNGt   LA(   R   R   (   t   modet   formatR   t   getmodebaset   convertt
   show_image(   t   selfR   R   t   base(    (    s7   /usr/local/lib/python2.7/dist-packages/PIL/ImageShow.pyR   @   s
    -c         C  s   |  j  S(   s.   Return format name, or None to save as PGM/PPM(   R   (   R   R   (    (    s7   /usr/local/lib/python2.7/dist-packages/PIL/ImageShow.pyt
   get_formatQ   s    c         K  s
   t  ‚ d  S(   N(   t   NotImplementedError(   R   t   fileR   (    (    s7   /usr/local/lib/python2.7/dist-packages/PIL/ImageShow.pyt   get_commandU   s    c         C  s   | j  d |  j | ƒ |  j  S(   s+   Save to temporary file, and return filenameR   (   t   _dumpR   R   (   R   R   (    (    s7   /usr/local/lib/python2.7/dist-packages/PIL/ImageShow.pyt
   save_imageX   s    c         K  s   |  j  |  j | ƒ |  S(   s   Display given image(   t	   show_fileR    (   R   R   R   (    (    s7   /usr/local/lib/python2.7/dist-packages/PIL/ImageShow.pyR   \   s    c         K  s   t  j |  j | |  ƒ d S(   s   Display given filei   (   t   ost   systemR   (   R   R   R   (    (    s7   /usr/local/lib/python2.7/dist-packages/PIL/ImageShow.pyR!   `   s    N(   t   __name__t
   __module__t   __doc__R   t   NoneR   R   R   R   R    R   R!   (    (    (    s7   /usr/local/lib/python2.7/dist-packages/PIL/ImageShow.pyR   ;   s   					t   win32t   WindowsViewerc           B  s$   e  Z d  Z i d d 6Z d „  Z RS(   R   i   t   compress_levelc         K  s   d | | f S(   NsD   start "Pillow" /WAIT "%s" && ping -n 2 127.0.0.1 >NUL && del /f "%s"(    (   R   R   R   (    (    s7   /usr/local/lib/python2.7/dist-packages/PIL/ImageShow.pyR   o   s    (   R$   R%   R   R   R   (    (    (    s7   /usr/local/lib/python2.7/dist-packages/PIL/ImageShow.pyR)   k   s   t   darwint	   MacViewerc           B  s-   e  Z d  Z i d d 6Z d „  Z d „  Z RS(   R   i   R*   c         K  s)   d } d | t  | ƒ t  | ƒ f } | S(   Ns   open -a Preview.apps   (%s %s; sleep 20; rm -f %s)&(   R   (   R   R   R   t   command(    (    s7   /usr/local/lib/python2.7/dist-packages/PIL/ImageShow.pyR   ~   s    	c         K  s   t  j ƒ  \ } } t j | d ƒ  } | j | ƒ Wd QXt | d ƒ # } t j d g d t d | ƒWd QXt j	 | ƒ d S(   s   Display given filet   wNt   rs7   im=$(cat); open -a Preview.app $im; sleep 20; rm -f $imt   shellt   stdini   (
   t   tempfilet   mkstempR"   t   fdopent   writet   opent
   subprocesst   Popent   Truet   remove(   R   R   R   t   fdt   patht   f(    (    s7   /usr/local/lib/python2.7/dist-packages/PIL/ImageShow.pyR!   ‰   s    	(   R$   R%   R   R   R   R!   (    (    (    s7   /usr/local/lib/python2.7/dist-packages/PIL/ImageShow.pyR,   z   s   	c         C  s}   t  j j d ƒ } | s d  SxZ | j t  j ƒ D]F } t  j j | |  ƒ } t  j j | ƒ r/ t  j	 | t  j
 ƒ r/ | Sq/ Wd  S(   Nt   PATH(   R"   t   environt   getR'   t   splitt   pathsepR<   t   joint   isfilet   accesst   X_OK(   t
   executableR<   t   dirnamet   filename(    (    s7   /usr/local/lib/python2.7/dist-packages/PIL/ImageShow.pyt   which   s    't
   UnixViewerc           B  s-   e  Z d  Z i d d 6Z d „  Z d „  Z RS(   R   i   R*   c         K  s3   |  j  | |  d } d | t | ƒ t | ƒ f S(   Ni    s   (%s %s; rm -f %s)&(   t   get_command_exR   (   R   R   R   R-   (    (    s7   /usr/local/lib/python2.7/dist-packages/PIL/ImageShow.pyR   «   s    c         K  s   t  j ƒ  \ } } t j | d ƒ  } | j | ƒ Wd QXt | d ƒ A } |  j | |  d } t j d | d g d t	 d | ƒWd QXt j
 | ƒ d	 S(
   s   Display given fileR.   NR/   i    s
   im=$(cat);s    $im; rm -f $imR0   R1   i   (   R2   R3   R"   R4   R5   R6   RL   R7   R8   R9   R:   (   R   R   R   R;   R<   R=   R-   (    (    s7   /usr/local/lib/python2.7/dist-packages/PIL/ImageShow.pyR!   ¯   s    $(   R$   R%   R   R   R   R!   (    (    (    s7   /usr/local/lib/python2.7/dist-packages/PIL/ImageShow.pyRK   §   s   	t   DisplayViewerc           B  s   e  Z d  „  Z RS(   c         K  s   d } } | | f S(   Nt   display(    (   R   R   R   R-   RG   (    (    s7   /usr/local/lib/python2.7/dist-packages/PIL/ImageShow.pyRL   ¿   s    
(   R$   R%   RL   (    (    (    s7   /usr/local/lib/python2.7/dist-packages/PIL/ImageShow.pyRM   ¾   s   RN   t	   EogViewerc           B  s   e  Z d  „  Z RS(   c         K  s   d } } | | f S(   Nt   eog(    (   R   R   R   R-   RG   (    (    s7   /usr/local/lib/python2.7/dist-packages/PIL/ImageShow.pyRL   Ç   s    
(   R$   R%   RL   (    (    (    s7   /usr/local/lib/python2.7/dist-packages/PIL/ImageShow.pyRO   Æ   s   RP   t   XVViewerc           B  s   e  Z d d  „ Z RS(   c         K  s1   d } } | r' | d t  | ƒ 7} n  | | f S(   Nt   xvs	    -name %s(   R   (   R   R   R   R   R-   RG   (    (    s7   /usr/local/lib/python2.7/dist-packages/PIL/ImageShow.pyRL   Ï   s    
N(   R$   R%   R'   RL   (    (    (    s7   /usr/local/lib/python2.7/dist-packages/PIL/ImageShow.pyRQ   Î   s   RR   t   __main__i   s-   Syntax: python ImageShow.py imagefile [title](!   t
   __future__R    R"   R7   t   sysR2   t   PILR   t   version_infot   majort   shlexR   t   pipesR   R   R'   R   t   objectR   t   platformR)   R,   RJ   RK   RM   RO   RQ   R$   t   lent   argvt   printt   exitR6   (    (    (    s7   /usr/local/lib/python2.7/dist-packages/PIL/ImageShow.pyt   <module>   sD   .	
	
