HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/env/lib/python3.10/site-packages/coverage/__pycache__/debug.cpython-310.pyc
o

!weGF�@s UdZddlmZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlmZmZmZmZmZmZmZmZmZmZddlmZmZddlmZee�ZgZ de!d<dZ"Gd	d
�d
�Z#Gdd�de#�Z$Gd
d�de#�Z%dhdd�Z&didd�Z'djdd�Z(dkd!d"�Z)dldmd'd(�Z*			dndod+d,�Z+dpdqd0d1�Z,drd3d4�Z-dsd5d6�Z.d7hZ/dtd:d;�Z0dud=d>�Z1dvd?d@�Z2dwdCdD�Z3GdEdF�dF�Z4GdGdH�dH�Z5dxdydMdN�Z6	O	Idzd{dUdV�Z7d|dXdY�Z8e�9�Z:e�9�Z;d7Z<	Z	I	Id}d~d^d_�Z=ddadb�Z>d�dfdg�Z?dS)�z'Control of and utilities for debugging.�)�annotationsN)
�cast�Any�Callable�IO�Iterable�Iterator�Mapping�Optional�List�Tuple)�human_sorted_items�isolate_module)�	TWritablez	List[str]�FORCED_DEBUGc@sPeZdZdZdZ	dddd
�Zddd�Zddd�Zej	ddd��Z
d dd�ZdS)!�DebugControlz!Control and output for debugging.FN�options�
Iterable[str]�output�Optional[IO[str]]�	file_name�
Optional[str]�return�NonecCsTt|�t|_d|_g}|�d�r|�t�tj|||�d�|d�|_	|j	j
|_dS)z4Configure the options and output file for debugging.F�pid�process)r�show_process�filtersN)�listrr�suppress_callers�should�append�add_pid_and_tid�DebugOutputFile�get_oner�outfile�
raw_output)�selfrrrr�r(�G/home/arjun/projects/env/lib/python3.10/site-packages/coverage/debug.py�__init__-s

�zDebugControl.__init__�strcCsd|j�d|j�d�S)Nz<DebugControl options=z raw_output=�>)rr&�r'r(r(r)�__repr__B�zDebugControl.__repr__�option�boolcCs|dkr	|jr	dS||jvS)z@Decide whether to output debug information in category `option`.�callersF)rr�r'r0r(r(r)r Es
zDebugControl.should�Iterator[None]ccs*�|j}d|_z	dVW||_dS||_w)z;A context manager to prevent call stacks from being logged.TN)r)r'�oldr(r(r)�without_callersKs�zDebugControl.without_callers�msgcCst|j�|d�|�d�r't��ddj�d�}|dur'|j�d|�d��|�d�r3t|jdd�|j��dS)	zhWrite a line of debug output.

        `msg` is the line to write. A newline will be appended.

        �
r'�rNzself: r2��out�skip)	r�writer �inspect�stack�f_locals�get�dump_stack_frames�flush)r'r7�caller_selfr(r(r)r=Us

zDebugControl.write�N)rrrrrrrr�rr+�r0r+rr1)rr4�r7r+rr)�__name__�
__module__�__qualname__�__doc__�show_repr_attrr*r.r �
contextlib�contextmanagerr6r=r(r(r(r)r(s�

	rcs,eZdZdZd�fdd�Zdd	d
�Z�ZS)
�DebugControlStringz8A `DebugControl` that writes to a StringIO, for testing.rrrrcst��|t���dSrE)�superr*�io�StringIO)r'r��	__class__r(r)r*gr/zDebugControlString.__init__r+cCstt|j���S)z,Get the output text from the `DebugControl`.)rr+r&�getvaluer-r(r(r)�
get_outputjszDebugControlString.get_output)rrrrrF)rIrJrKrLr*rW�
__classcell__r(r(rTr)rPesrPc@s.eZdZdZddd�Zdd	d
�Zddd
�ZdS)�NoDebuggingzBA replacement for DebugControl that will never try to do anything.rrcCsdSrEr(r-r(r(r)r*q�zNoDebugging.__init__r0r+r1cCsdS)z'Should we write debug messages?  Never.Fr(r3r(r(r)r urZzNoDebugging.shouldr7cCstd��)zThis will never be called.z)NoDebugging.write should never be called.)�AssertionError)r'r7r(r(r)r=yszNoDebugging.writeN�rrrGrH)rIrJrKrLr*r r=r(r(r(r)rYos


rY�labelr+rcCsd�d|d�S)zMake a nice header string.z
--{:-<60s}� ��format)r]r(r(r)�info_header~sra�info�Iterable[Tuple[str, Any]]�
Iterator[str]c#s��t|�}|s	dSd�t�fdd�|D��sJ�|D]L\}}|gkr$d}t|t�r>ttt|���dkr>d�|t|�fVqt|tttf�r^d�|f}|D]}d�d	||fVd
}qNqd�||fVqdS)z�Produce a sequence of formatted lines from info.

    `info` is a sequence of pairs (label, data).  The produced lines are
    nicely formatted, ready to print.

    N�c3s �|]\}}t|��kVqdSrE)�len)�.0�l�_��	label_lenr(r)�	<genexpr>�s�z!info_formatter.<locals>.<genexpr>z-none-z%*s: %rz%*s:z%*s %sr9�z%*s: %s)r�all�
isinstance�tuplerf�repr�set)rbr]�data�prefix�er(rjr)�info_formatter�s&���rvr=�Callable[[str], None]�headerrcCs,|t|��t|�D]	}|d|���q
dS)a,Write a sequence of (label,data) pairs nicely.

    `write` is a function write(str) that accepts each line of output.
    `header` is a string to start the section.  `info` is a sequence of
    (label, data) pairs, where label is a str, and data can be a single
    value, or a list/set/tuple.

    r^N)rarv)r=rxrb�liner(r(r)�write_formatted_info�s
�rz�exc�	ExceptioncCs$t�t|�|�}d�dd�|D��S)zIGet a one-line summary of an exception, including class name and message.�|css�|]}|��VqdSrE)�rstrip�rgrhr(r(r)rl���zexc_one_line.<locals>.<genexpr>)�	traceback�format_exception_only�type�join)r{�linesr(r(r)�exc_one_line�sr��limit�
Optional[int]r<�intcCs&t��||d�}d�dd�|D��S)a�Return a string summarizing the call stack.

    The string is multi-line, with one line per stack frame. Each line shows
    the function name, the file name, and the line number:

        ...
        start_import_stop : /Users/ned/coverage/trunk/tests/coveragetest.py @95
        import_local_file : /Users/ned/coverage/trunk/tests/coveragetest.py @81
        import_local_file : /Users/ned/coverage/trunk/coverage/backward.py @159
        ...

    `limit` is the number of frames to include, defaulting to all of them.

    `skip` is the number of frames to skip, so that debugging functions can
    call this and not be included in the result.

    ���r8css*�|]}d|d|d|dfVqdS)z%30s : %s:%d�r9�Nr()rg�tr(r(r)rl�s�(zshort_stack.<locals>.<genexpr>)r>r?r�)r�r<r?r(r(r)�short_stack�sr�r;�Optional[TWritable]cCs.|ptj}|�t||dd��|�d�dS)z:Print a summary of the stack to stdout, or someplace else.r9)r�r<r8N)�sys�stdoutr=r�)r�r;r<�foutr(r(r)rB�s
rB�2�text�numcharscCst��}||_|�|�S)z(`repr(text)`, but limited to `numchars`.)�reprlib�Repr�	maxstringrq)r�r��rr(r(r)�clipped_repr�s
r��id64cCs*d}tddd�D]}|||?N}q|d@S)z-Given a 64-bit id, make a shorter 16-bit one.r�@�i��)�range)r��id16�offsetr(r(r)�short_id�sr�cCs.tt���d�}t��d�d|�d|��}|S)z.A filter to add pid and tid to debug messages.�04x�5d�.z: )r��_thread�	get_ident�os�getpid)r��tidr(r(r)r"�sr"z$coverage.object_idr'rcCs<dd�|j��D�}dj|jjt|�d�dd�|D��d�S)z<A function implementing an automatic __repr__ for debugging.css8�|]\}}t|dd�rt|�s|tvr||fVqdS)rMTN)�getattr�callable�AUTO_REPR_IGNORE�rg�k�vr(r(r)rl�s�
����zauto_repr.<locals>.<genexpr>z<{klass} @0x{id:x} {attrs}>r^css"�|]\}}|�d|��VqdS)�=Nr(r�r(r(r)rl�s� )�klass�id�attrs)�__dict__�itemsr`rUrIr�r�)r'�
show_attrsr(r(r)�	auto_repr�s��r�r�cCsft|t�rdd�|��D�St|ttf�r t|�dd�|D��St|d�r1tdd�|j��D��S|S)z>Turn things which are nearly dict/list/etc into dict/list/etc.cSsi|]	\}}|t|��qSr(��simplify)rgr��vvr(r(r)�
<dictcomp>�zsimplify.<locals>.<dictcomp>cs��|]}t|�VqdSrEr�)rgr�r(r(r)rlr�zsimplify.<locals>.<genexpr>r�cSsi|]	\}}d||�qS)r�r(r�r(r(r)r�r�)	ro�dictr�rrpr��hasattrr�r��r�r(r(r)r��s

r�cCst�t|��dS)zEDebug helper to pretty-print data, including SimpleNamespace objects.N)�pprintr�r�r(r(r)�ppsr�r�Iterable[Callable[[str], str]]cCs\|��}|t|�d�}|}|D]}g}|��D]}|�||����qd�|�}q||S)z�Run `text` through a series of filters.

    `filters` is a list of functions. Each takes a string and returns a
    string.  Each is run in turn.

    Returns: the final string that results after all of the filters have
    run.

    Nr8)r~rf�
splitlines�extendr�)r�r�
clean_text�ending�fnr�ryr(r(r)�filter_texts
r�c@s$eZdZdZddd�Zddd	�Zd
S)
�
CwdTrackerz*A class to add cwd info to debug messages.rrcCs
d|_dSrE)�cwdr-r(r(r)r*(s
zCwdTracker.__init__r�r+cCs,t��}||jkrd|�d�|}||_|S)z#Add a cwd message for each new cwd.zcwd is now r8)r��getcwdr�)r'r�r�r(r(r)�filter+s

zCwdTracker.filterNr\�r�r+rr+)rIrJrKrLr*r�r(r(r(r)r�&s
r�c@szeZdZdZd&dd	�Ze	
	
			
d'd(dd��ZdZdZed)dd��Z	ed*dd��Z
ed+dd��Zd,d"d#�Zd+d$d%�Z
d
S)-r#z9A file-like object that includes pid and cwd information.r%rrr1rr�cCs�||_||_t|�|_|jrD|j�dt�j�|�dtj	�d��|�d�
ttdd���tt
d�rF|�dt
���dt
���d��dSdSdS)	NrzNew process: executable: r8zNew process: cmd: {!r}
�argv�getppidzNew process: pid: z, parent pid: )r%rrr�insertr�r�r=r��
executabler`r�r�r�r�r�)r'r%rrr(r(r)r*6s

$�zDebugOutputFile.__init__NTr(F�fileobjrr�interimrcCs�|dur
||||�S|��\}}|dus|rL|dur"t|ddd�}ntj�dt�}|dvr3tt|�}n
|r=t|ddd�}ntj}||||�}|�	||�|S)axGet a DebugOutputFile.

        If `fileobj` is provided, then a new DebugOutputFile is made with it.

        If `fileobj` isn't provided, then a file is chosen (`file_name` if
        provided, or COVERAGE_DEBUG_FILE, or stderr), and a process-wide
        singleton DebugOutputFile is made.

        `show_process` controls whether the debug file adds process-level
        information, and filters is a list of other message filters to apply.

        `filters` are the text filters to apply to the stream to annotate with
        pids, etc.

        If `interim` is true, then a future `get_one` can replace this one.

        N�azutf-8)�encoding�COVERAGE_DEBUG_FILE)r��stderr)
�_get_singleton_data�openr��environrA�FORCED_DEBUG_FILEr�r�r��_set_singleton_data)�clsr�rrrr��the_one�
is_interimr(r(r)r$GszDebugOutputFile.get_onez'$coverage.debug.DebugOutputFile.the_one�the_one_and_is_interimr�rcCs.t�|j�}t||j||f�|tj|j<dS)z-Set the one DebugOutputFile to rule them all.N)�types�
ModuleType�SYS_MOD_NAME�setattr�SINGLETON_ATTRr��modules)r�r�r��singleton_moduler(r(r)r�}sz#DebugOutputFile._set_singleton_data�&Tuple[Optional[DebugOutputFile], bool]cCstj�|j�}t||jd�S)zGet the one DebugOutputFile.)NT)r�r�rAr�r�r�)r�r�r(r(r)r��sz#DebugOutputFile._get_singleton_datacCs|jtjvr
tj|j=dSdS)z6Delete the one DebugOutputFile, just for tests to use.N)r�r�r�)r�r(r(r)�_del_singleton_data�s�z#DebugOutputFile._del_singleton_datar�r+cCs0|jdusJ�|j�t||j��|j��dS)z9Just like file.write, but filter through all our filters.N)r%r=r�rrC)r'r�r(r(r)r=�szDebugOutputFile.writecCs|jdusJ�|j��dS)zFlush our file.N)r%rCr-r(r(r)rC�szDebugOutputFile.flush)r%rrr1rr�)NNTr(F)r�rrrrr1rr�r�r1rr#)r�r#r�r1rr)rr�r\)r�r+rr)rIrJrKrLr*�classmethodr$r�r�r�r�r�r=rCr(r(r(r)r#4s(
�2
r#Fr7r?r1cCs2tjdd�}|�|d�|rt|dd�dSdS)z.Write a log message as forcefully as possible.T�r�r8r9r:N)r#r$r=rB)r7r?r;r(r(r)�log�s
�r�r(�	decorator�Callable[..., Any]�butnotr�privatecs���fdd�}|S)z2A class decorator to apply a decorator to methods.csZt�|tj�D]#\}}||jvrq|dkr�s|�d�rq|�vr"qt||�|��q|S)Nr*ri)r>�
getmembers�	isroutiner��
startswithr�)r��name�meth�r�r�r�r(r)�
_decorator�s
z$decorate_methods.<locals>._decoratorr()r�r�r�r�r(r�r)�decorate_methods�sr��funccst���d�fdd��}|S)	z;A function decorator to stop in the debugger for each call.�argsr�kwargsrcs&ddl}tjt_|���|i|��S�Nr)�pudbr��
__stdout__r��	set_trace)r�r�r��r�r(r)�_wrapper�szbreak_in_pudb.<locals>._wrapperN)r�rr�rrr��	functools�wraps�r�rr(rr)�
break_in_pudb�srT�	show_args�
show_stack�show_returncsd���fdd�}|S)z:A method decorator to debug-log each call to the function.r�r�rcs"t���d����fdd��}|S)	Nr'rr�r�rc
sLt|td�}|durt��d�dtt�d��}t|t|�d}�rMd�tt	|��}d�dd�|�
�D��}|d7}||7}|rE|rE|d7}||7}|d	7}�rb|d
7}|d�dd�t���D��7}tt
�}|�d|d�d�j�|�d
�}tjdd��|��|g|�Ri|��}	�r�|�d|d�d�j�d|	�d
�}tjdd��|�|	S)N�08dr^�04drmz, css�|]}dj|�VqdS)z{}={!r}Nr_)rg�itemr(r(r)rl�s�zCshow_calls.<locals>._decorator.<locals>._wrapper.<locals>.<genexpr>�(�)z @ z; csr�rE)�_clean_stack_linerr(r(r)rl�r�r8Tr�z return )r��OBJ_ID_ATTRr�r��next�OBJ_IDSr�r��maprqr�r�r��CALLSrIr#r$r=)
r'r�r��oid�extra�eargs�ekwargs�callidr7�ret)r�rr
r	r(r)r�s2 z0show_calls.<locals>._decorator.<locals>._wrapper)r'rr�rr�rrrrr�rr
r	rr)r��szshow_calls.<locals>._decoratorN�r�r�rr�r()rr	r
r�r(rr)�
show_calls�sr�scCsP|��}|�tj�t�dd�}|�tj�tj�dd�}|�tjdd�}|S)z6Simplify some paths in a stack trace, for compactness.�/rm)�strip�replacer��path�dirname�__file__r�rt)rr(r(r)r�s
r�env�Mapping[str, str]�List[Tuple[str, str]]cs�ddh}hd�}hd�}g}|��D]5\�}d}�|vrd}n
t�fdd�|D��r,d}|rGt�fd	d�|D��r@t�d
d|�}|��|f�qt|�S)aLFilter environment variables for a debug display.

    Select variables to display (with COV or PY in the name, or HOME, TEMP, or
    TMP), and also cloak sensitive values with asterisks.

    Arguments:
        env: a dict of environment variable names and values.

    Returns:
        A list of pairs (name, value) to show.

    �COV�PY>�TMP�HOME�TEMP>�API�KEY�PASS�TOKEN�SECRET�	SIGNATUREFTc3��|]}|�vVqdSrEr(�rg�slug�r�r(r)rlr�z/relevant_environment_display.<locals>.<genexpr>c3r4rEr(r5r7r(r)rlr�z\w�*)r��any�re�subr!r
)r&�slugs�include�cloak�to_show�val�keepr(r7r)�relevant_environment_display�s 
�rB)r]r+rr+)rbrcrrd)r=rwrxr+rbrcrr)r{r|rr+r�)r�r�r<r�rr+)NNr)r�r�r;r�r<r�rr)r�)r�r+r�r�rr+)r�r�rr�r�)r'rrr+)r�rrr)r�rrr)r�r+rr�rr+)F)r7r+r?r1rr)r(F)r�r�r�rr�r1rr�r)TFF)rr1r	r1r
r1rr�)rr+rr+)r&r'rr()@rL�
__future__rrNrr>rR�	itertoolsr�r�r:r�r�r�r�r��typingrrrrrrr	r
rr�
coverage.miscr
r�coverage.typesrr�__annotations__r�rrPrYrarvrzr�r�rBr�r�r"r�r�r�r�r�r�r#r�r�r�countrrrrrrBr(r(r(r)�<module>sr0=




�





h
�
�
&