ó
þ™xTc           @   s{   d  d l  m Z d  d l m Z d e f d „  ƒ  YZ e d k rw d  d l Z x& e j d D] Z e j	 e ƒ GHq\ Wn  d S(   iÿÿÿÿ(   t   division(   t	   FormatCBFt   FormatCBFMinic           B   s/   e  Z d  Z e d „  ƒ Z d „  Z d „  Z RS(   sz   An image reading class for mini CBF format images i.e. those from
  Dectris, which will read the header into a dictionary.c         C   s¹   t  j |  ƒ } d | k r+ d | k r+ t Sx‡ | j d ƒ D]v } d | k r] d | k r] t Sd | k ry d | k ry t Sd | k r• d | k r• t Sd | k r; d | k r; t Sq; Wt S(	   sV   Check to see if this looks like an CBF format image, i.e. we can
    make sense of it.s
   _diffrn.idt   _diffrn_sources   
s   _array_data.header_conventiont   PILATUSt   SLSt   ?s
   # Detector(   R   t   get_cbf_headert   Falset   splitt   True(   t
   image_filet   headert   record(    (    sH   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/format/FormatCBFMini.pyt
   understand   s"    c         C   s)   |  j  | ƒ s t ‚ t j |  | ƒ d S(   s3   Initialise the image structure from the given file.N(   R   t   AssertionErrorR   t   __init__(   t   selfR   (    (    sH   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/format/FormatCBFMini.pyR   .   s    c         C   sM  t  j |  ƒ t  j |  j ƒ } i  |  _ xÁ | j d ƒ D]° } d | d  k rT q8 n  t | d j ƒ  ƒ d k r¢ | j d ƒ d k r¢ | d j ƒ  |  j d <q8 n  | j	 d d ƒ j	 d d ƒ j ƒ  d } d	 j
 | d ƒ |  j | d
 <q8 WxZ |  j j d ƒ D]F } | j ƒ  sqÿ n  | j d ƒ \ } } | j ƒ  |  j | j ƒ  <qÿ Wd S(   s_   Open the image file, read the image header, copy it into a
    dictionary for future reference.s   
t   #i   i   t   :t	   timestampt   =t    t    i    N(   R   t   _startR   t   _image_filet   _cif_header_dictionaryR	   t   lent   countt   stript   replacet   joint   _mime_header(   R   t
   cif_headerR   t   tokenst   tokent   value(    (    sH   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/format/FormatCBFMini.pyR   7   s"    	1("(   t   __name__t
   __module__t   __doc__t   staticmethodR   R   R   (    (    (    sH   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/format/FormatCBFMini.pyR      s   		t   __main__Ni   (
   t
   __future__R    t   dxtbx.format.FormatCBFR   R   R%   t   syst   argvt   argR   (    (    (    sH   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/dxtbx/format/FormatCBFMini.pyt   <module>   s   D