Ñò
•µSJc           @   s  d  d k  Z  d  d k Z d  d k Z d  d k Z d d d „  ƒ  YZ d „  Z e d j o¦ d  d k Z d  d k Z e e i	 ƒ d j  o! d e i	 d GHe i
 d ƒ n xT e i	 d	 D]A Z e i e ƒ Z e d j o d
 e e i f GHq¶ d e GHq¶ Wn d S(   iÿÿÿÿNt   RAWc           B   s    e  Z d Z d  „  Z d „  Z RS(   c         C   s   d  S(   N(    (   t   self(    (    sU   /mnt/luc/web/www.saillard.org/www/programs_and_patches/photon/photon.hg/Photon/RAW.pyt   __init__   s    c         C   sQ   d |  i  | f } t i | ƒ \ } } | d j o d | GHd GH| GHd  Sd S(   Ns   dcraw -w -c "%s" > "%s"i    s?   ERROR: dcraw can not convert the image into a PPM file (err=%d)s   dcraw output:i   (   t   filenamet   commandst   getstatusoutputt   None(   R   t   outputfilenamet   dcrawcmdt   statust   resultstring(    (    sU   /mnt/luc/web/www.saillard.org/www/programs_and_patches/photon/photon.hg/Photon/RAW.pyt   convert   s    	N(   t   __name__t
   __module__R   t   formatR   R   (    (    (    sU   /mnt/luc/web/www.saillard.org/www/programs_and_patches/photon/photon.hg/Photon/RAW.pyR       s   	c         C   s¢   d |  } t  i | ƒ \ } } | d j o d | GHd GH| GHd  St i | d ƒ } | d j  o d GH| GHd  S| | d d !} t ƒ  } | | _ |  | _ | S(	   Ns   dcraw -i "%s"i    s2   ERROR: dcraw does not recognize the image (err=%d)s   dcraw output:s    is a s<   ERROR: Strange the string doesn't contains the magic string.i   iøÿÿÿ(   R   R   R   t   stringt   rfindR    R   R   (   R   R   R	   R
   t   idxR   t   raw(    (    sU   /mnt/luc/web/www.saillard.org/www/programs_and_patches/photon/photon.hg/Photon/RAW.pyt   identify3   s"    
				t   __main__i   s   Usage: %s files...
i    i   s   %s (format = %s)s   %s is not a RAW file(    (   t   osR   R   t   popen2R    R   R   t   syst   lent   argvt   exitR   t   infoR   R   (    (    (    sU   /mnt/luc/web/www.saillard.org/www/programs_and_patches/photon/photon.hg/Photon/RAW.pyt   <module>   s   0+	 
