Your IP : 216.73.216.213


Current Path : /opt/alt/python37/lib64/python3.7/site-packages/coverage/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/site-packages/coverage/__pycache__/misc.cpython-37.pyc

B

E�W��@s�dZddlZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mZmZm
Z
iZdd�Zee�Ze	jr�ddlmZddlmZd	d
�Zeddd
��e	jr�eddd
��ndd�Zdd
�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd1dd �ZGd!d"�d"e�Zd#d$�ZGd%d&�d&e�Z Gd'd(�d(e!�Z"Gd)d*�d*e"�Z#Gd+d,�d,e#�Z$Gd-d.�d.e"�Z%Gd/d0�d0e"�Z&dS)2z$Miscellaneous stuff for coverage.py.�N)�env)�string_class�to_bytes�
unicode_classcCs`|tkrXt�|j�}|t|<x:t|�D].}t||�}t|tj�rHt|�}t|||�q&Wt|S)aJCopy a module so that we are isolated from aggressive mocking.

    If a test suite mocks os.path.exists (for example), and then we need to use
    it during the test, everything will get tangled up if we use their mock.
    Making a copy of the module when we import it will isolate coverage.py from
    those complications.
    )	�ISOLATED_MODULES�types�
ModuleType�__name__�dir�getattr�
isinstance�isolate_module�setattr)�modZnew_mod�name�value�r�@/opt/alt/python37/lib64/python3.7/site-packages/coverage/misc.pyr
s
r
)�contract)�new_contractcOs$y
t||�Stk
rYnXdS)zEA proxy for contracts.new_contract that doesn't mind happening twice.N)�raw_new_contract�
ValueError)�args�kwargsrrrr/s
r�bytescCs
t|t�S)N)rr)�vrrr�<lambda>9�r�unicodecCs
t|t�S)N)rr)rrrrr;rcKsdd�S)z)Dummy no-op implementation of `contract`.cSs|S)Nr)�funcrrrrArzcontract.<locals>.<lambda>r)Zunusedrrrr?srcOsdS)z-Dummy no-op implementation of `new_contract`.Nr)Zargs_unusedZ
kwargs_unusedrrrrCscCs(|\}}||krd|Sd||fSdS)z�Make a nice string representation of a pair of numbers.

    If the numbers are equal, just return the number, otherwise return the pair
    with a dash between them, indicating the range.

    z%dz%d-%dNr)�pair�start�endrrr�	nice_pairHsr#cCs�g}d}d}d}t|�}t|�}xl|t|�kr�|t|�kr�||||krl|dkrZ||}||}|d7}n|r�|�||f�d}|d7}q"W|r�|�||f�d�tt|��}|S)a�Nicely format a list of line numbers.

    Format a list of line numbers for printing by coalescing groups of lines as
    long as the lines represent consecutive statements.  This will coalesce
    even if there are gaps between statements.

    For example, if `statements` is [1,2,3,4,5,10,11,12,13,14] and
    `lines` is [1,2,5,10,11,13,14] then the result will be "1-2, 5-11, 13-14".

    rN�z, )�sorted�len�append�join�mapr#)Z
statements�lines�pairs�i�jr!r"�retrrr�format_linesVs(
r/cs*tjr"d�j���fdd�}|S�SdS)z�A decorator to indicate that a method shouldn't be called more than once.

    Normally, this does nothing.  During testing, this raises an exception if
    called more than once.

    Z_once_cs,t|��rtd�j��t|�d��|�S)z%Inner function that checks the cache.z'Shouldn't have called %s more than onceT)�hasattr�	Exceptionr	r)�self)�attr�fnrr�_wrapped�s
zexpensive.<locals>._wrappedN)r�TESTINGr	)r4r5r)r3r4r�	expensivews

r7cCs|dkrdSt|�SdS)z"Return bool(b), but preserve None.N)�bool)�brrr�bool_or_none�sr:cCsd�dd�|D��S)z<Combine a list of regexes into one that matches any of them.�|css|]}d|VqdS)z(?:%s)Nr)�.0�rrrr�	<genexpr>�szjoin_regex.<locals>.<genexpr>)r()Zregexesrrr�
join_regex�sr?c
CsDyt�|�Wn0tk
r>}z|jtjkr.�Wdd}~XYnXdS)z9Remove a file, and don't get annoyed if it doesn't exist.N)�os�remove�OSError�errno�ENOENT)�path�errr�file_be_gone�s
rGcCs4|dkrtj}t|dd�p.ttjdd�p.t��}|S)zHDetermine the encoding to use for output written to `outfile` or stdout.N�encoding)�sys�stdoutr�
__stdout__�locale�getpreferredencoding)�outfilerHrrr�output_encoding�srOc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�HasherzHashes Python data into md5.cCst��|_dS)N)�hashlib�md5)r2rrr�__init__�szHasher.__init__cCs.|j�ttt|����t|t�r4|j�t|��n�t|t�rL|j�|�n�|dkrVn�t|tt	f�rz|j�tt|���n�t|t
tf�r�x�|D]}|�|�q�Wn�t|t�r�|�
�}xtt|�D]}|�|�|�||�q�WnJxHt|�D]<}|�d�r�q�t||�}t�|��rq�|�|�|�|�q�WdS)z+Add `v` to the hash, recursively if needed.N�__)rR�updater�str�typerrr�int�float�tuple�list�dict�keysr%r
�
startswithr�inspect�	isroutine)r2rrFr]�k�arrrrU�s2







z
Hasher.updatecCs
|j��S)z$Retrieve the hex digest of the hash.)rR�	hexdigest)r2rrrrc�szHasher.hexdigestN)r	�
__module__�__qualname__�__doc__rSrUrcrrrrrP�srPcCsDt|d�rd}|j}nd}|j}dj|d�}tdj|||d���dS)	z7Helper to raise NotImplementedError in interface stubs.�_coverage_plugin_nameZPluginZClassz#{klass.__module__}.{klass.__name__})�klassz1{thing} {name!r} needs to implement {func_name}())�thingr�	func_nameN)r0rg�	__class__�format�NotImplementedError)�thatrjrirrhrrr�_needs_to_implement�s
roc@seZdZdZdd�ZdS)�
SimpleReprz'A mixin implementing a simple __repr__.cCs2dj|jjt|�d@d�dd�|j��D��d�S)Nz<{klass} @{id:x} {attrs}>i���� css|]\}}d�||�VqdS)z{}={!r}N)rl)r<rarrrrr>�sz&SimpleRepr.__repr__.<locals>.<genexpr>)rh�id�attrs)rlrkr	rrr(�__dict__�items)r2rrr�__repr__�s
zSimpleRepr.__repr__N)r	rdrerfrvrrrrrp�srpc@seZdZdZdS)�CoverageExceptionz%An exception specific to coverage.py.N)r	rdrerfrrrrrw�srwc@seZdZdZdS)�NoSourcez)We couldn't find the source for a module.N)r	rdrerfrrrrrx�srxc@seZdZdZdS)�NoCodez!We couldn't find any code at all.N)r	rdrerfrrrrry�sryc@seZdZdZdS)�	NotPythonz3A source file turned out not to be parsable Python.N)r	rdrerfrrrrrz�srzc@seZdZdZdS)�ExceptionDuringRunz�An exception happened while running customer code.

    Construct it with three arguments, the values from `sys.exc_info`.

    N)r	rdrerfrrrrr{sr{)N)'rfrCrQr_rLr@rIr�coveragerZcoverage.backwardrrrrr
r6Z	contractsrrr�PY3r#r/r7r:r?rGrO�objectrProrpr1rwrxryrzr{rrrr�<module>sH
!	
'