ó
Ð²Ebc           @@  s=  d  d l  m Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l m Z m	 Z	 d  d l
 m Z d  d l m Z d  d l m Z d  d l m Z y d  d l Z Wn e k
 rÝ d  d l Z n Xy d  d l m Z Wn e k
 rd Z n Xd  d	 l m Z e Z e j ƒ  Z e	 d
 ƒ Z d e f d „  ƒ  YZ e rte rhd „  Z  qd „  Z  n e r†d „  Z  n	 d „  Z  e j! d d „ ƒ Z" d „  Z# d e j$ f d „  ƒ  YZ% d „  Z& d e j' f d „  ƒ  YZ( d e j) j* f d „  ƒ  YZ+ d e f d „  ƒ  YZ, d e f d „  ƒ  YZ- d „  Z. d S(    i    (   t   absolute_importN(   t   Filtert	   getLogger(   t   PY2(   t   WINDOWS(   t   DEPRECATION_MSG_PREFIX(   t
   ensure_dir(   t   colorama(   t   Fores   pip.subprocessort   BrokenStdoutLoggingErrorc           B@  s   e  Z d  Z RS(   sO   
    Raised if BrokenPipeError occurs for the stdout stream while logging.
    (   t   __name__t
   __module__t   __doc__(    (    (    s8   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/logging.pyR	   :   s   c         C@  s%   |  t  k o$ | j t j t j f k S(   s1   See the docstring for non-Windows Python 3 below.(   t   IOErrort   errnot   EINVALt   EPIPE(   t	   exc_classt   exc(    (    s8   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/logging.pyt   _is_broken_pipe_errorH   s    c         C@  s1   |  t  k p0 |  t k o0 | j t j t j f k S(   s1   See the docstring for non-Windows Python 3 below.(   t   BrokenPipeErrort   OSErrorR   R   R   (   R   R   (    (    s8   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/logging.pyR   N   s    c         C@  s   |  t  k o | j t j k S(   s1   See the docstring for non-Windows Python 3 below.(   R   R   R   (   R   R   (    (    s8   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/logging.pyR   T   s    c         C@  s
   |  t  k S(   s£   
        Return whether an exception is a broken pipe error.

        Args:
          exc_class: an exception class.
          exc: an exception instance.
        (   R   (   R   R   (    (    s8   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/logging.pyR   Y   s    i   c         c@  s;   t  ƒ  t _ t j |  7_ z	 d VWd t j |  8_ Xd S(   sv   
    A context manager which will cause the log output to be indented for any
    log messages emitted inside it.
    N(   t   get_indentationt
   _log_statet   indentation(   t   num(    (    s8   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/logging.pyt
   indent_logd   s
    	c           C@  s   t  t d d ƒ S(   NR   i    (   t   getattrR   (    (    (    s8   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/logging.pyR   s   s    t   IndentingFormatterc           B@  s#   e  Z d  „  Z d „  Z d „  Z RS(   c         O@  s2   | j  d t ƒ |  _ t t |  ƒ j | | Ž  d S(   sÎ   
        A logging.Formatter that obeys the indent_log() context manager.

        :param add_timestamp: A bool indicating output lines should be prefixed
            with their record's timestamp.
        t   add_timestampN(   t   popt   FalseR   t   superR   t   __init__(   t   selft   argst   kwargs(    (    s8   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/logging.pyR!   y   s    c         C@  s=   | t  j k  r d S| j t ƒ r& d S| t  j k  r9 d Sd S(   sv   
        Return the start of the formatted log message (not counting the
        prefix to add to each line).
        t    s	   WARNING: s   ERROR: (   t   loggingt   WARNINGt
   startswithR   t   ERROR(   R"   t	   formattedt   levelno(    (    s8   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/logging.pyt   get_message_startƒ   s    c         C@  s±   t  t |  ƒ j | ƒ } |  j | | j ƒ } | | } d } |  j rm |  j | d ƒ } d j t ƒ    } n  | d t ƒ  7} d j	 g  | j
 t ƒ D] } | | ^ q” ƒ } | S(   s†   
        Calls the standard formatter, but will indent all of the log message
        lines by our current indentation level.
        R%   s   %Y-%m-%dT%H:%M:%Ss   {t},{record.msecs:03.0f} t    (   R    R   t   formatR,   R+   R   t
   formatTimet   localsR   t   joint
   splitlinest   True(   R"   t   recordR*   t   message_startt   prefixt   tt   line(    (    s8   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/logging.pyR.   “   s    
	&(   R
   R   R!   R,   R.   (    (    (    s8   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/logging.pyR   w   s   	
	c          @  s   ‡  f d †  } | S(   Nc         @  s#   d j  t ˆ  ƒ |  t j j g ƒ S(   NR%   (   R1   t   listR   t   Stylet	   RESET_ALL(   t   inp(   t   colors(    s8   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/logging.pyt   wrappedª   s    (    (   R=   R>   (    (   R=   s8   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/logging.pyt   _color_wrap©   s    t   ColorizedStreamHandlerc           B@  sz   e  Z e r? e j e e j ƒ f e j e e j	 ƒ f g Z
 n g  Z
 d d d  „ Z d „  Z d „  Z d „  Z d „  Z RS(   c         C@  sD   t  j j |  | ƒ | |  _ t r@ t r@ t j |  j ƒ |  _ n  d  S(   N(   R&   t   StreamHandlerR!   t	   _no_colorR   R   t   AnsiToWin32t   stream(   R"   RD   t   no_color(    (    s8   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/logging.pyR!   »   s    	c         C@  s/   t  r t r |  j j t j k S|  j t j k S(   sA   
        Return whether the handler is using sys.stdout.
        (   R   R   RD   R>   t   syst   stdout(   R"   (    (    s8   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/logging.pyt   _using_stdoutÂ   s    c         C@  s}   t  s |  j r t St |  j t  j ƒ s2 |  j n	 |  j j } t | d ƒ r] | j ƒ  r] t	 St
 j j d ƒ d k ry t	 St S(   Nt   isattyt   TERMt   ANSI(   R   RB   R   t
   isinstanceRD   RC   R>   t   hasattrRI   R3   t   ost   environt   get(   R"   t   real_stream(    (    s8   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/logging.pyt   should_colorÌ   s    c         C@  sa   t  j j |  | ƒ } |  j ƒ  r] x9 |  j D]+ \ } } | j | k r+ | | ƒ } Pq+ q+ Wn  | S(   N(   R&   RA   R.   RR   t   COLORSR+   (   R"   R4   t   msgt   levelt   color(    (    s8   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/logging.pyR.   á   s    c         C@  sY   t  j ƒ  d  \ } } | rC |  j ƒ  rC t | | ƒ rC t ƒ  ‚ n  t t |  ƒ j | ƒ S(   Ni   (   RF   t   exc_infoRH   R   R	   R    R@   t   handleError(   R"   R4   R   R   (    (    s8   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/logging.pyRX   í   s
    N(   R
   R   R   R&   R)   R?   R   t   REDR'   t   YELLOWRS   t   NoneR!   RH   RR   R.   RX   (    (    (    s8   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/logging.pyR@   ¯   s   	
		t   BetterRotatingFileHandlerc           B@  s   e  Z d  „  Z RS(   c         C@  s,   t  t j j |  j ƒ ƒ t j j j |  ƒ S(   N(	   R   RN   t   patht   dirnamet   baseFilenameR&   t   handlerst   RotatingFileHandlert   _open(   R"   (    (    s8   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/logging.pyRb   ü   s    (   R
   R   Rb   (    (    (    s8   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/logging.pyR\   ú   s   t   MaxLevelFilterc           B@  s   e  Z d  „  Z d „  Z RS(   c         C@  s   | |  _  d  S(   N(   RU   (   R"   RU   (    (    s8   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/logging.pyR!     s    c         C@  s   | j  |  j k  S(   N(   R+   RU   (   R"   R4   (    (    s8   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/logging.pyt   filter  s    (   R
   R   R!   Rd   (    (    (    s8   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/logging.pyRc     s   	t   ExcludeLoggerFilterc           B@  s   e  Z d  Z d „  Z RS(   sQ   
    A logging Filter that excludes records from a logger (or its children).
    c         C@  s   t  t |  ƒ j | ƒ S(   N(   R    Re   Rd   (   R"   R4   (    (    s8   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/logging.pyRd     s    (   R
   R   R   Rd   (    (    (    s8   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/logging.pyRe   
  s   c         C@  s·  |  d k r d } nE |  d k r* d } n0 |  d k r? d } n |  d k rT d } n d	 } t  t | ƒ } | d2 k	 } | rŠ | } d } n d
 } | } | d3 k r¨ d n d } i d d 6d d 6}	 i d d 6d d 6}
 d d d g | rñ d g n g  } t j j i d d 6t d 6i i d d 6t j d 6d 6i d d 6t j d 6d 6i d  d 6t j d 6d! 6d" 6i i t	 d 6d# d$ 6d% 6i t	 d 6d# d$ 6t
 d& 6d' 6d( 6i i | d 6|
 d d) 6| d* 6|	 d d 6d! d g d" 6d% d+ 6d 6i d d 6|
 d d) 6| d* 6|	 d d 6d! g d" 6d% d+ 6d 6i | d 6|
 d d) 6| d* 6|	 d d 6d g d" 6d% d+ 6d 6i d d 6|
 d d) 6| d, 6t
 d- 6d' d+ 6d 6d. 6i | d 6| d. 6d/ 6i i | d 6d0 6d1 6ƒ | S(4   sn   Configures and sets up all of the logging

    Returns the requested logging level, as its integer value.
    i   t   DEBUGiÿÿÿÿR'   iþÿÿÿR)   iýÿÿÿt   CRITICALt   INFOs	   /dev/nulls   ext://sys.stdoutRG   s   ext://sys.stderrt   stderrs2   pip._internal.utils.logging.ColorizedStreamHandlerRD   s5   pip._internal.utils.logging.BetterRotatingFileHandlert   filet   consolet   console_errorst   console_subprocesst   user_logt   versiont   disable_existing_loggerss*   pip._internal.utils.logging.MaxLevelFilters   ()RU   t   exclude_warningss   logging.Filtert   namet   restrict_to_subprocesss/   pip._internal.utils.logging.ExcludeLoggerFiltert   exclude_subprocesst   filterss   %(message)sR.   t   indentR   t   indent_with_timestampt
   formatterst   classRE   t	   formattert   filenamet   delayR`   t   roots   pip._vendort   loggersN(   Rh   R)   (   R   R&   R[   t   configt
   dictConfigR   R'   t   subprocess_loggerRr   R   R3   (   t	   verbosityRE   t   user_log_fileRU   t   level_numbert   include_user_logt   additional_log_filet
   root_levelt   vendored_log_levelt   log_streamst   handler_classesR`   (    (    s8   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/logging.pyt   setup_logging  s¢    					



(/   t
   __future__R    t
   contextlibR   R&   t   logging.handlersRN   RF   R   R   t   pip._vendor.sixR   t   pip._internal.utils.compatR   t   pip._internal.utils.deprecationR   t   pip._internal.utils.miscR   t	   threadingt   ImportErrort   dummy_threadingt   pip._vendorR   t	   _coloramat	   ExceptionR[   t   pip._vendor.coloramaR   t   localR   R   R	   R   t   contextmanagerR   R   t	   FormatterR   R?   RA   R@   R`   Ra   R\   Rc   Re   R‹   (    (    (    s8   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/logging.pyt   <module>   sR   

				2	K	