ó
XxTc           @   sR   d  Z  d d l m Z d   Z e d k rN d d l Z e d e j d  n  d S(   s  Simple script for post-processing output of TAPENADE at:

  http://tapenade.inria.fr:8080/tapenade/paste.jsp

TAPENADE is an Automatic Differentiation Engine developed at INRIA
Sophia-Antipolis by the TROPICS team.

http://www-sop.inria.fr/tropics/tapenade.html
i˙˙˙˙(   t   divisionc         C   sě  g  } t  } x0 |  D]( } | d k r. t } q | j |  q Wt d j    } i d d 6} g  } x:| D]2} t |  } xt |  j   j   D]}	 |	 j   }	 |	 | k rş q n  |	 j	 d  r'|	 j
   }
 t |
  d k sí t  d j |
 d d	 ! d
 k st  |
 d	 | |
 d <q n  | rB|	 j	 d  rBq n  |	 d k r]t |  } n/ x, | j   D] \ } } |	 j | |  }	 qjW| j |	  q Wqk Wx6 t |  d k rŮt | d  d k rŮ| j   q¤Wd j |  GHd  S(   Ns   --no-commentssl         INCLUDE 'DIFFSIZES.inc'
C  Hint: nbdirsmax should be the maximum number of differentiation directions
t   nbdirst	   nbdirsmaxs	   C  Hint: i	   t    i   i   s   should be the value ofi   t   Cs	         ENDi    i˙˙˙˙s   
(   t   Falset   Truet   appendt   sett
   splitlinest   dictt   opent   readt   rstript
   startswitht   splitt   lent   AssertionErrort   joint   itemst   replacet   pop(   t   argst
   file_namest   no_commentst   argt   lines_to_ignoret   default_replacement_dictt   output_linest	   file_namet   replacement_dictt   linet   fldst   oldt   new(    (    sV   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/scitbx/command_line/apply_tapenade_hints.pyt   run   s@    	"+t   __main__NR   i   (   t   __doc__t
   __future__R    R#   t   __name__t   syst   argv(    (    (    sV   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/scitbx/command_line/apply_tapenade_hints.pyt   <module>
   s
   	&