
NXc           @   sC   d  d l  Z  d  d l Z d  d l Z d   Z d   Z d   Z d S(   iNc         C   s   t  j j |   } t  j j |  s( t St  j |  j } t j j	 d  r} t  j
   d k r} t | t j t j Bt j B@ St  j | t  j  S(   s   Checks that path is an executable regular file, or a symlink towards one.

    This is roughly ``os.path isfile(path) and os.access(path, os.X_OK)``.
    t   sunosi    (   t   ost   patht   realpatht   isfilet   Falset   statt   st_modet   syst   platformt
   startswitht   getuidt   boolt   S_IXUSRt   S_IXGRPt   S_IXOTHt   accesst   X_OK(   R   t   fpatht   mode(    (    sE   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/pexpect/utils.pyt   is_executable_file   s    c         C   s   t  j j |   d k r( t |   r( |  Sd t  j k sJ t  j d d k rV t  j } n t  j d } | j t  j  } x3 | D]+ } t  j j | |   } t |  r| | Sq| Wd S(   s   This takes a given filename; tries to find it in the environment path;
    then checks if it is executable. This returns the full path to the filename
    if found and executable. Otherwise this returns None.t    t   PATHN(
   R   R   t   dirnameR   t   environt   defpatht   splitt   pathsept   joint   None(   t   filenamet   pt   pathlistR   t   ff(    (    sE   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/pexpect/utils.pyt   which"   s    $"c   
      C   s  g  } d } d } d } d } d } d } | } x.|  D]&}	 | | k sU | | k r |	 d k rj | } q]|	 d k r | } q]|	 d	 k r | } q]|	 j    r | | k r d
 q | j |  d } | } q]| |	 } | } q7 | | k r| |	 } | } q7 | | k r/|	 d k r"| } q]| |	 } q7 | | k r7 |	 d	 k rP| } q]| |	 } q7 q7 W| d k r}| j |  n  | S(   s  This splits a command line into a list of arguments. It splits arguments
    on spaces, but handles embedded quotes, doublequotes, and escaped
    characters. It's impossible to do this with a regular expression, so I
    wrote a little state machine to parse the command line. R   i    i   i   i   i   s   \t   't   "N(   t   isspaceR   t   append(
   t   command_linet   arg_listt   argt   state_basict	   state_esct   state_singlequotet   state_doublequotet   state_whitespacet   statet   c(    (    sE   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/pexpect/utils.pyt   split_command_line6   sL    				
	
			(   R   R   R   R   R"   R1   (    (    (    sE   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/pexpect/utils.pyt   <module>   s
   		