ó
ÐEe]c           @   sÞ   d  Z  d d l Z d d l Z d d l Z y d d l m Z Wn! e k
 ra d d l m Z n Xd d d g Z d d d „  ƒ  YZ d d d	 „  ƒ  YZ	 d d d
 „  ƒ  YZ
 e j d k rÂ e	 Z n e j d k rÚ e
 Z n  d S(   sq   
Helper functions for interacting with the shell, and consuming shell-style
parameters provided in config files.
iÿÿÿÿN(   t   quotet   WindowsParsert   PosixParsert   NativeParsert   CommandLineParserc           B   s,   e  Z d  Z e d „  ƒ Z e d „  ƒ Z RS(   s  
    An object that knows how to split and join command-line arguments.

    It must be true that ``argv == split(join(argv))`` for all ``argv``.
    The reverse neednt be true - `join(split(cmd))` may result in the addition
    or removal of unnecessary escaping.
    c         C   s
   t  ‚ d S(   s5    Join a list of arguments into a command line string N(   t   NotImplemented(   t   argv(    (    s;   lib/python2.7/site-packages/numpy/distutils/_shell_utils.pyt   join   s    c         C   s
   t  ‚ d S(   s6    Split a command line string into a list of arguments N(   R   (   t   cmd(    (    s;   lib/python2.7/site-packages/numpy/distutils/_shell_utils.pyt   split   s    (   t   __name__t
   __module__t   __doc__t   staticmethodR   R	   (    (    (    s;   lib/python2.7/site-packages/numpy/distutils/_shell_utils.pyR      s   c           B   s,   e  Z d  Z e d „  ƒ Z e d „  ƒ Z RS(   s¯   
    The parsing behavior used by `subprocess.call("string")` on Windows, which
    matches the Microsoft C/C++ runtime.

    Note that this is _not_ the behavior of cmd.
    c         C   s   t  j |  ƒ S(   N(   t
   subprocesst   list2cmdline(   R   (    (    s;   lib/python2.7/site-packages/numpy/distutils/_shell_utils.pyR   *   s    c         C   s  d d  l  } y | j Wn t k
 r0 t ‚ n X|  s; g  Sd |  }  | j j j } | j | j ƒ | _ | j | j | j	 ƒ f | _
 | j	 ƒ  } | |  | j | ƒ ƒ } g  t | j ƒ D] } | | ^ q» } | j j j | ƒ sí t ‚ | d d k st ‚ | d S(   Niÿÿÿÿs   dummy i    t   dummyi   (   t   ctypest   windllt   AttributeErrort   NotImplementedErrort   shell32t   CommandLineToArgvWt   POINTERt	   c_wchar_pt   restypet   c_intt   argtypest   byreft   ranget   valuet   kernel32t	   LocalFreet   AssertionError(   R   R   R   t   nargst   lpargst   it   args(    (    s;   lib/python2.7/site-packages/numpy/distutils/_shell_utils.pyR	   /   s"    

&(   R
   R   R   R   R   R	   (    (    (    s;   lib/python2.7/site-packages/numpy/distutils/_shell_utils.pyR   #   s   c           B   s,   e  Z d  Z e d „  ƒ Z e d „  ƒ Z RS(   sX   
    The parsing behavior used by `subprocess.call("string", shell=True)` on Posix.
    c         C   s   d j  d „  |  Dƒ ƒ S(   Nt    c         s   s   |  ] } t  | ƒ Vq d  S(   N(   R    (   t   .0t   arg(    (    s;   lib/python2.7/site-packages/numpy/distutils/_shell_utils.pys	   <genexpr>Q   s    (   R   (   R   (    (    s;   lib/python2.7/site-packages/numpy/distutils/_shell_utils.pyR   O   s    c         C   s   t  j |  d t ƒS(   Nt   posix(   t   shlexR	   t   True(   R   (    (    s;   lib/python2.7/site-packages/numpy/distutils/_shell_utils.pyR	   S   s    (   R
   R   R   R   R   R	   (    (    (    s;   lib/python2.7/site-packages/numpy/distutils/_shell_utils.pyR   K   s   t   ntR)   (    (    (    (   R   t   osR*   R   R    t   ImportErrort   pipest   __all__R   R   R   t   nameR   (    (    (    s;   lib/python2.7/site-packages/numpy/distutils/_shell_utils.pyt   <module>   s   (	