ó
šxTc           @   sœ   d  d l  m Z y d  d l Z Wn* e k
 rL d  d l m Z e d ‚ n Xd e j f d „  ƒ  YZ d e j f d „  ƒ  YZ d	 e j	 f d
 „  ƒ  YZ
 d S(   iÿÿÿÿ(   t	   tbx_utilsN(   t   SorrysA   The argparse module is not available. Check Python version >= 2.7t   PhilPrintActionc           B   s2   e  Z d  Z e j e j d d „ Z d d „ Z RS(   s   
    Action to print phil
    c         C   s5   t  t |  ƒ j d | d | d | d d d | ƒ d  S(   Nt   option_stringst   destt   defaultt   nargsi    t   help(   t   superR   t   __init__(   t   selfR   R   R   R   (    (    s8   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/phaser/cli.pyR	      s    c         C   s   | j  ƒ  | j ƒ  d  S(   N(   t
   print_philt   exit(   R
   t   parsert	   namespacet   valuest   option_string(    (    s8   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/phaser/cli.pyt   __call__    s    
N(   t   __name__t
   __module__t   __doc__t   argparset   SUPPRESSt   NoneR	   R   (    (    (    s8   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/phaser/cli.pyR      s
   t   CaptureStdinPhilActionc           B   s,   e  Z d  Z e j d d „ Z d d „ Z RS(   s!   
    Action to capture stdin
    c         C   s5   t  t |  ƒ j d | d | d | d d d | ƒ d  S(   NR   R   R   R   i    R   (   R   R   R	   (   R
   R   R   R   R   (    (    s8   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/phaser/cli.pyR	   .   s    c         C   sl   d d  l  } y" t j j d | j j ƒ  ƒ } Wn$ t k
 rT } | j d | ƒ n Xt | |  j	 | ƒ d  S(   Niÿÿÿÿt   strings#   Error while reading from stdin: %s
(
   t   sysR    t   PhilArgumentt   from_stringt   stdint   readt
   ValueErrort   errort   setattrR   (   R
   R   R   R   R   R   t   valuet   e(    (    s8   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/phaser/cli.pyR   9   s    "N(   R   R   R   R   R   R   R	   R   (    (    (    s8   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/phaser/cli.pyR   )   s   t
   PCLIParserc           B   s>   e  Z d  Z d „  Z d d „ Z d d „ Z d d d „ Z RS(   s4   
    Extended parser that handles help and phil
    c         O   sÎ   t  t |  ƒ j | | Ž  | |  _ |  j d d d d d d d d g  d	 t j d
 | ƒ d d ƒd |  j k rt d n
 |  j d } |  j | d d d t d d ƒ|  j | d | d d d t	 d d ƒd  S(   Nt   philsR   t   *t   metavart   PHILt   actiont   storeR   t   typet   master_philR   s9   PHIL argument (file name or PHIL command line assignment)t   -i    i   s   show-defaultss   print PHIL and exitt   iR   s   read PHIL from stdin as well(
   R   R$   R	   R,   t   add_argumentR    t   PhilArgumentFactoryt   prefix_charsR   R   (   R
   R,   t   argst   kwargst   default_prefix(    (    s8   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/phaser/cli.pyR	   K   s&    	"c         C   s}   | d  k r t j j } n  t t |  ƒ j |  j ƒ  | ƒ t t |  ƒ j d | ƒ t t |  ƒ j |  j j	 ƒ  d | ƒ d  S(   Ns   
PHIL definition:
s   
(
   R   R   t   _syst   stdoutR   R$   t   _print_messaget   format_helpR,   t   as_str(   R
   t   file(    (    s8   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/phaser/cli.pyt
   print_helpg   s    c         C   sE   | d  k r t j j } n  t t |  ƒ j |  j j ƒ  d | ƒ d  S(   Ns   
(	   R   R   R5   R6   R   R$   R7   R,   R9   (   R
   R:   (    (    s8   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/phaser/cli.pyR   t   s
    c         C   sW   t  t |  ƒ j d | d | ƒ } t | d ƒ rS | j j | j ƒ t | d ƒ n  | S(   NR2   R   R   (   R   R$   t
   parse_argst   hasattrR%   t   appendR   t   delattr(   R
   R2   R   (    (    s8   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/phaser/cli.pyR<      s    	N(   R   R   R   R	   R   R;   R   R<   (    (    (    s8   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/phaser/cli.pyR$   F   s
   	(   t   phaserR    R   t   ImportErrort   libtbx.utilsR   t   ActionR   R   t   ArgumentParserR$   (    (    (    s8   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/phaser/cli.pyt   <module>   s   