3
���h5
� @ s� d Z ddlZddlZddlZyddlmZ W n ek
rL ddlmZ Y nX dddgZG dd� d�ZG d d� d�Z G d
d� d�Z
ejdkr�e Znejdkr�e
ZdS )
zq
Helper functions for interacting with the shell, and consuming shell-style
parameters provided in config files.
� N)�quote�
WindowsParser�PosixParser�NativeParserc @ s( e Zd ZdZedd� �Zedd� �ZdS )�CommandLineParsera
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 �dS )z5 Join a list of arguments into a command line string N)�NotImplementedError)�argv� r �=/tmp/pip-build-5_djhm0z/numpy/numpy/distutils/_shell_utils.py�join s zCommandLineParser.joinc C s t �dS )z6 Split a command line string into a list of arguments N)r )�cmdr r r
�split s zCommandLineParser.splitN)�__name__�
__module__�__qualname__�__doc__�staticmethodr r
r r r r
r s r c @ s( e Zd ZdZedd� �Zedd� �ZdS )r z�
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)�
subprocess�list2cmdline)r r r r
r * s zWindowsParser.joinc s� dd l }y
|j W n tk
r* t�Y nX | s4g S d| } |jjj}|j|j�|_|j|j|j �f|_
|j � }|| |j|��� � fdd�t|j
�D �}|jjj� � s�t�|d dks�t�|dd � S )Nr zdummy c s g | ]}� | �qS r r )�.0�i)�lpargsr r
�
<listcomp>C s z'WindowsParser.split.<locals>.<listcomp>�dummy� )�ctypes�windll�AttributeErrorr �shell32�CommandLineToArgvW�POINTER� c_wchar_p�restype�c_int�argtypes�byref�range�value�kernel32Z LocalFree�AssertionError)r r r �nargs�argsr )r r
r
/ s" |