ó
žS]c           @@  sN   d  Z  d d l m Z d d l Z d e f d     YZ d   Z d   Z d S(   s"   Windows command line manipulation.i    (   t   absolute_importNt   WindowsCommandLineExceptionc           B@  s   e  Z RS(    (   t   __name__t
   __module__(    (    (    sH   lib/python2.7/site-packages/anaconda_project/internal/windows_cmdline.pyR      s   c         C@  sf  d d l  m } m } m } m } d d l m } m } m } | j	 j
 } | | |  g | _ | |  | _ | j j }	 | g |	 _ | |	 _ | d  }
 | |  | |
   } | sÏ t d t |     n  z g  } d } xr | |
 j k  rRy | j t | |   Wn7 t k
 rD} d |  d t |  } t |   n X| d 7} qá WWd  |	 |  X| S(   Ni    (   t   windllt   c_intt   POINTERt   byref(   t   LPCWSTRt   LPWSTRt   HLOCALs&   Windows could not parse command line: sF   Windows cannot represent this command line in its character encoding: s   : i   (   t   ctypesR   R   R   R   t   ctypes.wintypesR   R	   R
   t   shell32t   CommandLineToArgvWt   argtypest   restypet   kernel32t	   LocalFreeR   t   strt   valuet   appendt   UnicodeEncodeError(   t   commandR   R   R   R   R   R	   R
   R   R   t   argct   argvt   resultt   it   et   message(    (    sH   lib/python2.7/site-packages/anaconda_project/internal/windows_cmdline.pyt   windows_split_command_line   s0    "	c         C@  sū   t  |   d k r! t d   n  |  d j d  rK t d |  d   n  d |  d k r d |  d k r t d |  d   n  |  d } d | k rĨ d | } n  | d t j |  d  S(	   s^  Combine an argv into a Windows command line.

    Note: this can throw on some args you might pass in, but it should not throw
    on args you got from windows_split_command_line, because those are args
    that are representable as a command line. In other words, we throw on args
    that windows_split_command_line won't be able to reproduce.
    i    s@   Windows has no way to encode an empty arg list as a command linet   "s<   Windows does not allow the first arg to start with a quote: t    sE   Windows does not allow the first arg to have both quotes and spaces: s   "%s"i   (   t   lenR   t
   startswitht
   subprocesst   list2cmdline(   t   argst	   first_arg(    (    sH   lib/python2.7/site-packages/anaconda_project/internal/windows_cmdline.pyt   windows_join_command_line5   s    
 
(   t   __doc__t
   __future__R    R#   t	   ExceptionR   R   R'   (    (    (    sH   lib/python2.7/site-packages/anaconda_project/internal/windows_cmdline.pyt   <module>   s
   	#