ó
ÝJþMc           @   s·   d  d l  Z  d  d l Z d d l m Z m Z m Z m Z d d l m Z m	 Z	 m
 Z
 d d l m Z e d k	 r~ e ƒ  Z n  d „  Z d e f d „  ƒ  YZ d	 e f d
 „  ƒ  YZ d S(   iÿÿÿÿNi   (   t   AnsiForet   AnsiBackt	   AnsiStylet   Style(   t   WinTermt   WinColort   WinStyle(   t   windllc         C   s   t  |  d ƒ o |  j ƒ  S(   Nt   isatty(   t   hasattrR   (   t   stream(    (    sK   /afs/sipb.mit.edu/user/vasilvv/arch/amd64_deb70/bin/colorama/ansitowin32.pyt   is_a_tty   s    t   StreamWrapperc           B   s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   s´   
    Wraps a stream (such as stdout), acting as a transparent proxy for all
    attribute access apart from method 'write()', which is delegated to our
    Converter instance.
    c         C   s   | |  _  | |  _ d  S(   N(   t   _StreamWrapper__wrappedt   _StreamWrapper__convertor(   t   selft   wrappedt	   converter(    (    sK   /afs/sipb.mit.edu/user/vasilvv/arch/amd64_deb70/bin/colorama/ansitowin32.pyt   __init__   s    	c         C   s   t  |  j | ƒ S(   N(   t   getattrR   (   R   t   name(    (    sK   /afs/sipb.mit.edu/user/vasilvv/arch/amd64_deb70/bin/colorama/ansitowin32.pyt   __getattr__   s    c         C   s   |  j  j | ƒ d  S(   N(   R   t   write(   R   t   text(    (    sK   /afs/sipb.mit.edu/user/vasilvv/arch/amd64_deb70/bin/colorama/ansitowin32.pyR   !   s    (   t   __name__t
   __module__t   __doc__R   R   R   (    (    (    sK   /afs/sipb.mit.edu/user/vasilvv/arch/amd64_deb70/bin/colorama/ansitowin32.pyR      s   		t   AnsiToWin32c           B   s€   e  Z d  Z e j d ƒ Z d d e d „ Z d „  Z	 d „  Z
 d „  Z d „  Z d „  Z d „  Z d	 „  Z d
 „  Z d „  Z RS(   s¾   
    Implements a 'write()' method which, on Windows, will strip ANSI character
    sequences from the text, and if outputting to a tty, will convert them into
    win32 function calls.
    s   \[((?:\d|;)*)([a-zA-Z])c         C   s¦   | |  _  | |  _ t | |  ƒ |  _ t j j d ƒ } | d  k rK | } n  | |  _ | d  k ru | oo t	 | ƒ } n  | |  _
 |  j ƒ  |  _ |  j  t j k |  _ d  S(   Nt   win(   R   t	   autoresetR   R
   t   syst   platformt
   startswitht   Nonet   stripR   t   convertt   get_win32_callst   win32_callst   stderrt	   on_stderr(   R   R   R#   R"   R   t
   on_windows(    (    sK   /afs/sipb.mit.edu/user/vasilvv/arch/amd64_deb70/bin/colorama/ansitowin32.pyR   -   s    					c         C   s   |  j  p |  j p |  j S(   sj  
        True if this class is actually needed. If false, then the output
        stream will not be affected, nor will win32 calls be issued, so
        wrapping stdout is not actually required. This will generally be
        False on non-Windows platforms, unless optional functionality like
        autoreset has been requested using kwargs to init()
        (   R#   R"   R   (   R   (    (    sK   /afs/sipb.mit.edu/user/vasilvv/arch/amd64_deb70/bin/colorama/ansitowin32.pyt   should_wrapJ   s    c         C   sé  |  j  råt råi t j f t j 6t j t j f t j 6t j t j f t j	 6t j t j f t j 6t j
 t j f t j 6t j
 t j f t j 6t j
 t j f t j 6t j
 t j f t j 6t j
 t j f t j 6t j
 t j f t j 6t j
 t j f t j 6t j
 t j f t j 6t j
 f t j 6t j t j f t j 6t j t j f t j 6t j t j f t j 6t j t j f t j 6t j t j f t j 6t j t j f t j 6t j t j f t j 6t j t j f t j 6t j f t j 6Sd  S(   N(   R#   t   wintermt	   reset_allR   t	   RESET_ALLt   styleR   t   BRIGHTt   NORMALt   DIMt   foreR   t   BLACKR    t   REDt   GREENt   YELLOWt   BLUEt   MAGENTAt   CYANt   GREYt   WHITEt   RESETt   backR   (   R   (    (    sK   /afs/sipb.mit.edu/user/vasilvv/arch/amd64_deb70/bin/colorama/ansitowin32.pyR$   U   s0    c         C   sY   |  j  s |  j r" |  j | ƒ n |  j j | ƒ |  j j ƒ  |  j rU |  j ƒ  n  d  S(   N(   R"   R#   t   write_and_convertR   R   t   flushR   R+   (   R   R   (    (    sK   /afs/sipb.mit.edu/user/vasilvv/arch/amd64_deb70/bin/colorama/ansitowin32.pyR   q   s    	c         C   sE   |  j  r |  j d d ƒ n% t |  j ƒ rA |  j j t j ƒ n  d  S(   Nt   mi    (   i    (   R#   t
   call_win32R   R   R   R   R,   (   R   (    (    sK   /afs/sipb.mit.edu/user/vasilvv/arch/amd64_deb70/bin/colorama/ansitowin32.pyR+   {   s    	c         C   s~   d } xX |  j  j | ƒ D]D } | j ƒ  \ } } |  j | | | ƒ |  j | j ƒ  Œ  | } q W|  j | | t | ƒ ƒ d S(   sª   
        Write the given text to our wrapped stream, stripping any ANSI
        sequences from the text, and optionally converting them into win32
        calls.
        i    N(   t   ANSI_REt   finditert   spant   write_plain_textt   convert_ansit   groupst   len(   R   R   t   cursort   matcht   startt   end(    (    sK   /afs/sipb.mit.edu/user/vasilvv/arch/amd64_deb70/bin/colorama/ansitowin32.pyR=   ‚   s    
c         C   s7   | | k  r3 |  j  j | | | !ƒ |  j  j ƒ  n  d  S(   N(   R   R   R>   (   R   R   RJ   RK   (    (    sK   /afs/sipb.mit.edu/user/vasilvv/arch/amd64_deb70/bin/colorama/ansitowin32.pyRD   ‘   s    c         C   s/   |  j  r+ |  j | ƒ } |  j | | ƒ n  d  S(   N(   R#   t   extract_paramsR@   (   R   t   paramstringt   commandt   params(    (    sK   /afs/sipb.mit.edu/user/vasilvv/arch/amd64_deb70/bin/colorama/ansitowin32.pyRE   —   s    	c         C   s   d „  } t  | | ƒ ƒ S(   Nc         s   s8   x1 |  j  d ƒ D]  } | d k r t | ƒ Vq q Wd  S(   Nt   ;t    (   t   splitt   int(   RM   t   p(    (    sK   /afs/sipb.mit.edu/user/vasilvv/arch/amd64_deb70/bin/colorama/ansitowin32.pyRR   ž   s    (   t   tuple(   R   RM   RR   (    (    sK   /afs/sipb.mit.edu/user/vasilvv/arch/amd64_deb70/bin/colorama/ansitowin32.pyRL      s    	c         C   sä   | g  k r d g } n  | d k rŠ x¹ | D]X } | |  j  k r+ |  j  | } | d } | d } t d |  j ƒ } | | | Ž  q+ q+ WnV | d k rµ t j } | | d |  j ƒn+ | d k rà t j } | | d |  j ƒn  d  S(	   Ni    R?   i   R'   t   Ht   ft   J(   RV   RW   (   R%   t   dictR'   R*   t   set_cursor_positiont
   erase_data(   R   RN   RO   t   paramt	   func_argst   funct   argst   kwargs(    (    sK   /afs/sipb.mit.edu/user/vasilvv/arch/amd64_deb70/bin/colorama/ansitowin32.pyR@   ¥   s     

		N(   R   R   R   t   ret   compileRA   R!   t   FalseR   R)   R$   R   R+   R=   RD   RE   RL   R@   (    (    (    sK   /afs/sipb.mit.edu/user/vasilvv/arch/amd64_deb70/bin/colorama/ansitowin32.pyR   %   s   			
					(   Ra   R   t   ansiR    R   R   R   R*   R   R   R   t   win32R   R!   R   t   objectR   R   (    (    (    sK   /afs/sipb.mit.edu/user/vasilvv/arch/amd64_deb70/bin/colorama/ansitowin32.pyt   <module>   s   "	