3 Re%3@sddlmZddlZddlZddlZddlZddlZddlZddlmZm Z ddl m Z ddl m Z ddlmZddlmZy ddlZWnek rddlZYnXyddlmZWnek rdZYnXdd lmZeZejZe d ZGd d d eZe r e rd dZnddZne r0ddZnddZej d%ddZ!ddZ"Gdddej#Z$ddZ%Gdddej&Z'Gdddej(j)Z*Gdd d eZ+Gd!d"d"eZ,d#d$Z-dS)&)absolute_importN)Filter getLogger)PY2)WINDOWS)DEPRECATION_MSG_PREFIX) ensure_dir)colorama)Forezpip.subprocessorc@seZdZdZdS)BrokenStdoutLoggingErrorzO Raised if BrokenPipeError occurs for the stdout stream while logging. N)__name__ __module__ __qualname____doc__rr/builddir/build/BUILDROOT/alt-python36-pip-20.2.4-5.el9.x86_64/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/utils/logging.pyr :sr cCs|tko|jtjtjfkS)z1See the docstring for non-Windows Python 3 below.)IOErrorerrnoEINVALEPIPE) exc_classexcrrr_is_broken_pipe_errorHsrcCs"|tkp |tko |jtjtjfkS)z1See the docstring for non-Windows Python 3 below.)BrokenPipeErrorOSErrorrrr)rrrrrrNscCs|tko|jtjkS)z1See the docstring for non-Windows Python 3 below.)rrr)rrrrrrTscCs|tkS)z Return whether an exception is a broken pipe error. Args: exc_class: an exception class. exc: an exception instance. )r)rrrrrrYsc cs6tt_tj|7_z dVWdtj|8_XdS)zv A context manager which will cause the log output to be indented for any log messages emitted inside it. N)get_indentation _log_state indentation)numrrr indent_logds  r cCs ttddS)Nrr)getattrrrrrrrssrcs0eZdZfddZddZfddZZS)IndentingFormattercs$|jdd|_tt|j||dS)z 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. add_timestampFN)popr#superr"__init__)selfargskwargs) __class__rrr&yszIndentingFormatter.__init__cCs.|tjkrdS|jtrdS|tjkr*dSdS)zv Return the start of the formatted log message (not counting the prefix to add to each line). z WARNING: zERROR: )loggingWARNING startswithrERROR)r' formattedlevelnorrrget_message_starts   z$IndentingFormatter.get_message_startcsztt|j|}|j||j}||}d|jrJ|j|d}djftdt7dj fdd|j dD}|S)z Calls the standard formatter, but will indent all of the log message lines by our current indentation level. r+z%Y-%m-%dT%H:%M:%Sz{t},{record.msecs:03.0f}  csg|] }|qSrr).0line)prefixrr sz-IndentingFormatter.format..T) r%r"formatr2r1r# formatTimelocalsrjoin splitlines)r'recordr0 message_startt)r*)r6rr8s  zIndentingFormatter.format)r r rr&r2r8 __classcell__rr)r*rr"ws r"csfdd}|S)Ncsdjt|tjjgS)Nr+)r;listr Style RESET_ALL)inp)colorsrrwrappedsz_color_wrap..wrappedr)rErFr)rEr _color_wraps rGcsheZdZer.ejeejfej eej fgZ ngZ d ddZ ddZ ddZdd Zfd d ZZS) ColorizedStreamHandlerNcCs.tjj||||_tr*tr*tj|j|_dS)N)r, StreamHandlerr& _no_colorrr AnsiToWin32stream)r'rLno_colorrrrr&szColorizedStreamHandler.__init__cCs"trtr|jjtjkS|jtjkS)zA Return whether the handler is using sys.stdout. )rr rLrFsysstdout)r'rrr _using_stdoutsz$ColorizedStreamHandler._using_stdoutcCsZt s |jrdSt|jtjs$|jn|jj}t|drB|jrBdStj j ddkrVdSdS)NFisattyTTERMANSI) r rJ isinstancerLrKrFhasattrrQosenvironget)r' real_streamrrr should_colors z#ColorizedStreamHandler.should_colorcCsBtjj||}|jr>x&|jD]\}}|j|kr||}PqW|S)N)r,rIr8rZCOLORSr1)r'r=msglevelcolorrrrr8s zColorizedStreamHandler.formatcs@tjdd\}}|r0|jr0t||r0ttt|j|S)Nr)rNexc_inforPrr r%rH handleError)r'r=rr)r*rrr`s   z"ColorizedStreamHandler.handleError)NN)r r rr r,r/rGr REDr-YELLOWr[r&rPrZr8r`r@rr)r*rrHs   rHc@seZdZddZdS)BetterRotatingFileHandlercCs ttjj|jtjjj|S)N) rrVpathdirname baseFilenamer,handlersRotatingFileHandler_open)r'rrrriszBetterRotatingFileHandler._openN)r r rrirrrrrcsrcc@seZdZddZddZdS)MaxLevelFiltercCs ||_dS)N)r])r'r]rrrr&szMaxLevelFilter.__init__cCs |j|jkS)N)r1r])r'r=rrrfilterszMaxLevelFilter.filterN)r r rr&rkrrrrrjsrjcs eZdZdZfddZZS)ExcludeLoggerFilterzQ A logging Filter that excludes records from a logger (or its children). cstt|j| S)N)r%rlrk)r'r=)r*rrrkszExcludeLoggerFilter.filter)r r rrrkr@rr)r*rrl srlc Csf|dkrd}n.|d1krd}n |d2kr*d}n|d3kr8d}nd}tt|}|d k }|r\|}d}nd }|}|d4krpdnd}d d d } ddd} dddg|rdgng} tjjdddtjddtjddtjddtddtdddd || d!|| d"d#d$gd%d&d| d!|| d'd#gd%d&|| d!|| d'd(gd%d&d| d)|dd*d+d,|| d-d.d/|iid0|S)5znConfigures and sets up all of the logging Returns the requested logging level, as its integer value. DEBUGr-rr/CRITICALINFONz /dev/nullzext://sys.stdoutzext://sys.stderr)rOstderrz2pip._internal.utils.logging.ColorizedStreamHandlerz5pip._internal.utils.logging.BetterRotatingFileHandler)rLfileconsoleconsole_errorsconsole_subprocessuser_logFz*pip._internal.utils.logging.MaxLevelFilter)z()r]zlogging.Filter)z()namez/pip._internal.utils.logging.ExcludeLoggerFilter)exclude_warningsrestrict_to_subprocessexclude_subprocessz %(message)s)z()r8T)z()r8r#)indentindent_with_timestamprLrOr{ryr|)r]classrMrLfilters formatterrrrzrsr})r]r~filenamedelayr)rtrurvrw)r]rgz pip._vendorr])versiondisable_existing_loggersr formattersrgrootloggers)rqr/)r!r,config dictConfigr-subprocess_loggerrxr") verbosityrM user_log_filer] level_numberinclude_user_logadditional_log_file root_levelvendored_log_level log_streamshandler_classesrgrrr setup_loggings    r)r). __future__r contextlibrr,logging.handlersrVrNrrZpip._vendor.sixrpip._internal.utils.compatrpip._internal.utils.deprecationrpip._internal.utils.miscr threading ImportErrordummy_threading pip._vendorr _colorama ExceptionZpip._vendor.coloramar localrrr rcontextmanagerr r Formatterr"rGrIrHrgrhrcrjrlrrrrrsR              2K