Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
B

=*”´`?kÇã@spdZddlZddlZddlZddlZddlZddlZddlmZddl	m
Z
ddlmZddl
mZmZmZddlmZmZmZmZmZddlmZmZmZGd	d
„d
ƒZGdd„dƒZGd
d„dƒZGdd„deƒZGdd„deƒZGdd„deƒZ Gdd„deƒZ!Gdd„de "dd¡ƒZ#eddd„ƒGdd„dƒZ$d d!„Z%Gd"d#„d#ƒZ&d$gZ'd%d&„Z(de)fd'd(„Z*dS))zCode parsing for coverage.py.éN)Úenv)Úcode_objects)Úshort_stack)ÚNoSourceÚ	NotPythonÚ_StopEverything)ÚcontractÚ
join_regexÚnew_contractÚ	nice_pairÚone_of)Úcompile_unicodeÚgenerate_tokensÚneuter_encoding_declarationc@s~eZdZdZeddddd„ƒZdd„Zd	d
„Zdd„Zd
d„Z	dd„Z
dd„Zdd„Zdd„Z
dd„Zdd„Zddd„ZdS)ÚPythonParserz™Parse code to find executable lines, excluded lines, etc.

    This information is all based on static analysis: no code execution is
    involved.

    zunicode|None)ÚtextNc
CsÖ|s|stdƒ‚|pd|_||_|js~ddlm}y||jƒ|_Wn:tk
r|}ztd|j›d|›ƒ|‚Wdd}~XYnX||_|j d¡|_	t
ƒ|_t
ƒ|_t
ƒ|_
t
ƒ|_t
ƒ|_d	|_i|_d|_d|_dS)
z¿
        Source can be provided as `text`, the text itself, or `filename`, from
        which the text will be read.  Excluded lines are those that match
        `exclude`, a regex.

        z*PythonParser needs either text or filenamez<code>r)Úget_python_sourcezNo source for code: 'z': NÚ
F)ÚAssertionErrorÚfilenamerZcoverage.pythonrÚOSErrorrÚexcludeÚsplitÚlinesÚsetÚ
statementsÚexcludedÚraw_statementsÚraw_excludedÚraw_docstringsÚshow_tokensÚ
_multilineÚ	_all_arcsÚ_missing_arc_fragments)ÚselfrrrrÚerr©r&úŽ/build/wlanpi-profiler-7IIg1Q/wlanpi-profiler-1.0.11/debian/wlanpi-profiler/opt/wlanpi-profiler/lib/python3.7/site-packages/coverage/parser.pyÚ__init__s(
*zPythonParser.__init__cGsLt|ƒ}t |¡}tƒ}x.t|jddD]\}}| |¡r(| |¡q(W|S)zêFind the lines matching one of a list of regexes.

        Returns a set of line numbers, the lines that contain a match for one
        of the regexes in `regexes`.  The entire line needn't match, just a
        part of it.

        é)Ústart)r	ÚreÚcompilerÚ	enumeraterÚsearchÚadd)r$ZregexesZcombinedZregex_cÚmatchesÚiÚltextr&r&r'Úlines_matchingTs

zPythonParser.lines_matchingcCsŽ|jr| |j¡|_d}d}d}d}tj}d}d}d}d}	t|jƒ}
xú|
D]ð\}}\}
}\}}}|jrtdt	j
 ||¡t|
|fƒ||fƒ|tjkr¦|d7}nB|tj
kr¼|d8}n,|tjkrl|dkr|	dkr||jkpè|}|sj|rj|j |¡|}d}d}nZ|dkrD|rD||jkr0d}|rj|j |¡n&|d	krX|	d7}	n|d
krè|	d8}	n||tjkrœ|tjkrœ|j t|
|dƒ¡nL|tjkrè|dk	rà||kràx"t||dƒD]}||j|<qÌWd}d}| ¡r:|t	jkr:d}|dkr:|
}|r$||kr$d}|r6|j |¡d}|}qLW|sht|j|jd}|j | ¡¡tjjrŠ|jrŠt|jƒ|jd<dS)zwParse the source to find the interesting facts about its lines.

        A handful of attributes are updated.

        rFNTz%10s %5s %-20r %rr)ú:ú@z([{z)]})r) rr3rÚtokenÚINDENTrrr ÚprintÚtokenizeÚtok_nameÚgetrÚDEDENTÚOPr/ÚSTRINGrÚupdateÚrangeÚNEWLINEr!ÚstripÚCOMMENTÚ
ByteParserrrÚ_find_statementsrÚ
PYBEHAVIORÚmodule_firstline_1Úmin)r$ÚindentZexclude_indentZ	excludingZexcluding_decoratorsZprev_toktypeÚ
first_lineÚemptyZ
first_on_lineZnestingZtokgenZtoktypeZttextZslinenoÚ_Zelinenor2Zshould_excludeÚlZbyte_parserr&r&r'Ú
_raw_parsedsz
 






zPythonParser._raw_parsecCs0|dkr|j ||¡}n|j ||¡}|S)z?Return the first line number of the statement including `line`.r)r!r;)r$Úliner&r&r'rJÅszPythonParser.first_linecs‡fdd„|DƒS)zˆMap the line numbers in `lines` to the correct first line of the
        statement.

        Returns a set of the first lines.

        csh|]}ˆ |¡’qSr&)rJ)Ú.0rM)r$r&r'ú	<setcomp>Ôsz+PythonParser.first_lines.<locals>.<setcomp>r&)r$rr&)r$r'Úfirst_linesÍszPythonParser.first_linescCs
| |¡S)z)Implement `FileReporter.translate_lines`.)rR)r$rr&r&r'Útranslate_linesÖszPythonParser.translate_linescs‡fdd„|DƒS)z(Implement `FileReporter.translate_arcs`.cs$g|]\}}ˆ |¡ˆ |¡f‘qSr&)rJ)rPÚaÚb)r$r&r'ú
<listcomp>Üsz/PythonParser.translate_arcs.<locals>.<listcomp>r&)r$Úarcsr&)r$r'Útranslate_arcsÚszPythonParser.translate_arcsc
Cs¶y| ¡Wnptjtfk
r|}zLt|dƒr6|j}n|jdd}td|j›d|jd›d|›ƒ|‚Wdd}~XYnX| 	|j
¡|_|j|jB}|j
|}| 	|¡||_dS)zÁParse source text to find executable lines, excluded lines, etc.

        Sets the .excluded and .statements attributes, normalized to the first
        line of multi-line statements.

        Úlinenor)rzCouldn't parse 'z' as Python source: z	 at line N)rNr9Ú
TokenErrorÚIndentationErrorÚhasattrrYÚargsrrrRrrrrr)r$r%rYÚignoreÚstartsr&r&r'Úparse_sourceÞs

zPythonParser.parse_sourcecCs|jdkr| ¡|jS)zÃGet information about the arcs available in the code.

        Returns a set of line number pairs.  Line numbers have been normalized
        to the first line of multi-line statements.

        N)r"Ú_analyze_ast)r$r&r&r'rW÷s
zPythonParser.arcscCsnt|j|j|jƒ}| ¡tƒ|_x>|jD]4\}}| |¡}| |¡}||kr*|j 	||f¡q*W|j
|_dS)zkRun the AstArcAnalyzer and save its results.

        `_all_arcs` is the set of arcs in the code.

        N)ÚAstArcAnalyzerrrr!Úanalyzerr"rWrJr/Úmissing_arc_fragmentsr#)r$ZaaaÚl1Úl2Zfl1Zfl2r&r&r'ras

zPythonParser._analyze_astcCsVt t¡}xF| ¡D]:\}}|dkr&q||jkr2q||jkr>q||d7<qW|S)zYGet a count of exits from that each line.

        Excluded lines are excluded.

        rr))ÚcollectionsÚdefaultdictÚintrWr)r$Úexit_countsrerfr&r&r'rjs


zPythonParser.exit_countsc
Cs|jdkr| ¡|}|rP|dkrP||krP||f|krP||f|jkrP||}}|j ||fdg¡}g}xŒ|D]„\}}|dkr®|dkrª||f|jkr¤| ||¡Sd}nd}|j|d}d|›d|›}	|dk	rè|	d	|j|d›7}	| |	¡qnWd
 |¡S)z5Provide an English sentence describing a missing arc.Nr)NNz didn't jump to the function exitzdidn't jump to line {lineno})rYzline ú z
, because z or )r#rar;Úmissing_arc_descriptionÚformatÚappendÚjoin)
r$r*ÚendZ
executed_arcsZactual_startZfragment_pairsZmsgsÚsmsgÚemsgÚmsgr&r&r'rl)s.

z$PythonParser.missing_arc_description)NNN)N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__rr(r3rNrJrRrSrXr`rWrarjrlr&r&r&r'rs7a	rc@s<eZdZdZeddd
dd„ƒZdd„Zd	d
„Zdd„ZdS)rDz3Parse bytecode to understand the structure of code.Úunicode)rNc
Cs†||_|r||_nNyt||dƒ|_Wn:tk
r^}ztd||j|jfƒ|‚Wdd}~XYnXx dD]}t|j|ƒsftdƒ‚qfWdS)NÚexecz5Couldn't parse '%s' as Python source: '%s' at line %d)Ú	co_lnotabÚco_firstlinenozsThis implementation of Python doesn't support code analysis.
Run coverage.py under another Python for this command.)	rÚcoder
ÚSyntaxErrorrrsrYr\r)r$rr|rZsynerrÚattrr&r&r'r(Ts
zByteParser.__init__cs‡fdd„tˆjƒDƒS)z~Iterate over all the code objects nested within this one.

        The iteration includes `self` as its first value.

        c3s|]}tˆj|dVqdS))r|N)rDr)rPÚc)r$r&r'ú	<genexpr>rsz+ByteParser.child_parsers.<locals>.<genexpr>)rr|)r$r&)r$r'Ú
child_parserslszByteParser.child_parsersc
csÒt|jdƒr6xÀ|j ¡D]\}}}|dk	r|VqWn˜|jjddd…}|jjddd…}d}|jj}d}xTt||ƒD]F\}}	|rœ||kr”|V|}||7}tjjr´|	dkr´|	d8}	||	7}qvW||krÎ|VdS)z·Yield the line numbers possible in this code object.

        Uses co_lnotab described in Python/compile.c to find the
        line numbers.  Produces a sequence: l0, l1, ...
        Úco_linesNrér)é€é)	r\r|r‚rzr{ÚziprrFZnegative_lnotab)
r$rLrOÚbyte_incrementsÚline_incrementsZ
last_line_numÚline_numZbyte_numÚ	byte_incrÚ	line_incrr&r&r'Ú
_line_numbersts(zByteParser._line_numbersccs$x| ¡D]}| ¡EdHq
WdS)z´Find the statements in `self.code`.

        Produce a sequence of line numbers that start statements.  Recurses
        into all code objects reachable from `self.code`.

        N)rrŒ)r$Zbpr&r&r'rE’szByteParser._find_statements)NN)	rtrurvrwrr(rrŒrEr&r&r&r'rDQsrDc@s0eZdZdZdd„Zdd„Zdd„Zdd	„Zd
S)Ú	BlockBasea;
    Blocks need to handle various exiting statements in their own ways.

    All of these methods take a list of exits, and a callable `add_arc`
    function that they can use to add arcs if needed.  They return True if the
    exits are handled, or False if the search should continue up the block
    stack.
    cCst‚dS)zProcess break exits.N)r)r$ÚexitsÚadd_arcr&r&r'Úprocess_break_exits¬szBlockBase.process_break_exitscCst‚dS)zProcess continue exits.N)r)r$rŽrr&r&r'Úprocess_continue_exits²sz BlockBase.process_continue_exitscCsdS)zProcess raise exits.Fr&)r$rŽrr&r&r'Úprocess_raise_exits¸szBlockBase.process_raise_exitscCsdS)zProcess return exits.Fr&)r$rŽrr&r&r'Úprocess_return_exits¼szBlockBase.process_return_exitsN)rtrurvrwrr‘r’r“r&r&r&r'r¢s
rc@s2eZdZdZeeddd„ƒZdd„Zdd„Zd	S)
Ú	LoopBlockz@A block on the block stack representing a `for` or `while` loop.)r*cCs||_tƒ|_dS)N)r*rÚbreak_exits)r$r*r&r&r'r(ÃszLoopBlock.__init__cCs|j |¡dS)NT)r•r?)r$rŽrr&r&r'rÊszLoopBlock.process_break_exitscCs$x|D]}||j|j|jƒqWdS)NT)rYr*Úcause)r$rŽrÚxitr&r&r'r‘Îs
z LoopBlock.process_continue_exitsN)	rtrurvrwrrir(rr‘r&r&r&r'r”Ásr”c@s4eZdZdZeeeddd„ƒZdd„Zdd„Z	d	S)
Ú
FunctionBlockz>A block on the block stack representing a function definition.)r*ÚnamecCs||_||_dS)N)r*r™)r$r*r™r&r&r'r(ÖszFunctionBlock.__init__cCs0x*|D]"}||j|j|jd|j›ƒqWdS)Nzdidn't except from function T)rYr*r–r™)r$rŽrr—r&r&r'r’Ýs

z!FunctionBlock.process_raise_exitscCs0x*|D]"}||j|j|jd|j›ƒqWdS)Nzdidn't return from function T)rYr*r–r™)r$rŽrr—r&r&r'r“ås

z"FunctionBlock.process_return_exitsN)
rtrurvrwrriÚstrr(r’r“r&r&r&r'r˜Ôsr˜c@sDeZdZdZeddddd„ƒZdd„Zdd	„Zd
d„Zdd
„Z	dS)ÚTryBlockz6A block on the block stack representing a `try` block.zint|None)Ú
handler_startÚfinal_startcCs0||_||_tƒ|_tƒ|_tƒ|_tƒ|_dS)N)rœrrÚ
break_fromÚ
continue_fromÚ
raise_fromÚreturn_from)r$rœrr&r&r'r(ðszTryBlock.__init__cCs|jdk	r|j |¡dSdS)NTF)rržr?)r$rŽrr&r&r'rþs
zTryBlock.process_break_exitscCs|jdk	r|j |¡dSdS)NTF)rrŸr?)r$rŽrr&r&r'r‘s
zTryBlock.process_continue_exitscCsJ|jdk	r,x:|D]}||j|j|jƒqWn|jdk	s:t‚|j |¡dS)NT)rœrYr–rrr r?)r$rŽrr—r&r&r'r’
s

zTryBlock.process_raise_exitscCs|jdk	r|j |¡dSdS)NTF)rr¡r?)r$rŽrr&r&r'r“s
zTryBlock.process_return_exitsN)
rtrurvrwrr(rr‘r’r“r&r&r&r'r›îs	r›c@sLeZdZdZeeddd„ƒZddd„Zdd	„Zd
d„Z	dd
„Z
dd„ZdS)Ú	WithBlockz7A block on the block stack representing a `with` block.)r*cCs.tjjst‚||_tƒ|_tƒ|_tƒ|_dS)N)	rrFÚexit_through_withrr*rržrŸr¡)r$r*r&r&r'r(s
zWithBlock.__init__NcCs6x|D]}||j|j|jƒqW|dk	r2| |¡dS)z*Helper to process the four kinds of exits.NT)rYr*r–r?)r$rŽrZfrom_setr—r&r&r'Ú_process_exits+s


zWithBlock._process_exitscCs| |||j¡S)N)r¤rž)r$rŽrr&r&r'r3szWithBlock.process_break_exitscCs| |||j¡S)N)r¤rŸ)r$rŽrr&r&r'r‘6sz WithBlock.process_continue_exitscCs| ||¡S)N)r¤)r$rŽrr&r&r'r’9szWithBlock.process_raise_exitscCs| |||j¡S)N)r¤r¡)r$rŽrr&r&r'r“<szWithBlock.process_return_exits)N)rtrurvrwrrir(r¤rr‘r’r“r&r&r&r'r¢s
r¢cs"eZdZdZd‡fdd„	Z‡ZS)ÚArcStarta¸The information needed to start an arc.

    `lineno` is the line number the arc starts from.

    `cause` is an English text fragment used as the `startmsg` for
    AstArcAnalyzer.missing_arc_fragments.  It will be used to describe why an
    arc wasn't executed, so should fit well into a sentence of the form,
    "Line 17 didn't run because {cause}."  The fragment can include "{lineno}"
    to have `lineno` interpolated into it.

    Ncstƒ |||¡S)N)ÚsuperÚ__new__)ÚclsrYr–)Ú	__class__r&r'r§LszArcStart.__new__)N)rtrurvrwr§Ú
__classcell__r&r&)r©r'r¥@sr¥ZArcz
lineno, causeÚ	ArcStartscCstdd„|DƒƒS)Ncss|]}t|tƒVqdS)N)Ú
isinstancer¥)rPÚxr&r&r'r€Rsz<lambda>.<locals>.<genexpr>)Úall)Úseqr&r&r'Ú<lambda>Rór°c@seZdZdZdd„ZdS)ÚNodeListzÁA synthetic fictitious node, containing a sequence of nodes.

    This is used when collapsing optimized if-statements, to represent the
    unconditional execution of one of the clauses.

    cCs||_|dj|_dS)Nr)ÚbodyrY)r$r³r&r&r'r(\szNodeList.__init__N)rtrurvrwr(r&r&r&r'r²Usr²cCst t|ƒ¡S)zHow we create an AST parse.)ÚastÚparser)rr&r&r'Ú	ast_parsedsr¶c@s–eZdZdZededdd„ƒZdd„Zeeeddgd
d„ƒZ	dd
„Z
eeddd„ƒZdd„Zdd„Z
eZdd„ZeZeZdd„Zdd„Zdddddd d!d"d#d$d%hZed&dd'd(„ƒZed)ƒed&ddhd*d+„ƒƒZd,d-„Zd.d/„Zd0d1„Zd2d3„Zd4d5„Zed&d6d7d8„ƒZed&d6d9d:„ƒZed&d6d;d<„ƒZed&d6d=d>„ƒZ ed&dd?d@„ƒZ!ed&ddAdB„ƒZ"e"Z#ed&ddCdD„ƒZ$ed&ddEdF„ƒZ%e%Z&e"Z'e"Z(ed&ddGdH„ƒZ)ed&ddIdJ„ƒZ*ed&ddKdL„ƒZ+ed&ddMdN„ƒZ,ed&ddOdP„ƒZ-ed&ddQdR„ƒZ.ed&d&d&dSdTdU„ƒZ/ed&ddVdW„ƒZ0ed&ddXdY„ƒZ1e1Z2dZd[„Z3d\d]„Z4e4Z5d^d_„Z6d`da„Z7e7dbƒZ8e7dcƒZ9e7ddƒZ:e7deƒZ;e7dfƒZ<d	S)irbz>Analyze source text with an AST to find executable code paths.rx)rrcsžt|ƒ|_‡fdd„|Dƒ|_ˆ|_tttj dd¡ƒƒ}|rht	d|j›ƒt	d|j›ƒt
|jƒtƒ|_t
 t¡|_g|_tttj dd¡ƒƒ|_dS)Ncsh|]}ˆ ||¡’qSr&)r;)rPrM)Ú	multiliner&r'rQpsz*AstArcAnalyzer.__init__.<locals>.<setcomp>ZCOVERAGE_AST_DUMPrzStatements: zMultiline map: ZCOVERAGE_TRACK_ARCS)r¶Ú	root_noderr·ÚboolriÚosÚenvironr;r8Úast_dumprrWrgrhÚlistrdÚblock_stackÚdebug)r$rrr·Zdump_astr&)r·r'r(ls

zAstArcAnalyzer.__init__cCsBx<t |j¡D],}|jj}t|d|dƒ}|dk	r||ƒqWdS)z¨Examine the AST tree from `root_node` to determine possible arcs.

        This sets the `arcs` attribute to be a set of (from, to) line number
        pairs.

        Z_code_object__N)r´Úwalkr¸r©rtÚgetattr)r$ÚnodeÚ	node_nameZcode_object_handlerr&r&r'rcŠs
zAstArcAnalyzer.analyze)r*rpNc	Csp|jr4td|›d|›d|›d|›ƒttddƒ|j ||f¡|dk	sT|dk	rl|j||f ||f¡dS)z@Add an arc, including message fragments to use if it is missing.z
Adding arc: (z, z): é)ÚlimitN)r¿r8rrWr/rdrn)r$r*rprqrrr&r&r'r—s zAstArcAnalyzer.add_arccCs
t|jƒS)z.Yield the blocks in nearest-to-farthest order.)Úreversedr¾)r$r&r&r'Únearest_blocks¢szAstArcAnalyzer.nearest_blocks)ÚreturnscCs2|jj}t|d|dƒ}|dk	r(||ƒS|jSdS)z}What is the right line number to use for this node?

        This dispatches to _line__Node functions where needed.

        Z_line__N)r©rtrÁrY)r$rÂrÃÚhandlerr&r&r'Ú
line_for_node¦s
zAstArcAnalyzer.line_for_nodecCs$|j}tjjr |jr |jdj}|S)zSCompute first line number for things that can be decorated (classes and functions).r)rYrrFÚtrace_decorated_defÚdecorator_list)r$rÂrYr&r&r'Ú_line_decorated´s
zAstArcAnalyzer._line_decoratedcCs| |j¡S)N)rÊÚvalue)r$rÂr&r&r'Ú
_line__Assign¼szAstArcAnalyzer._line__AssigncCs8|jr.|jddk	r |jdjS|jdjSn|jSdS)Nr)ÚkeysrYÚvalues)r$rÂr&r&r'Ú_line__DictÁs
zAstArcAnalyzer._line__DictcCs |jr| |jd¡S|jSdS)Nr)ZeltsrÊrY)r$rÂr&r&r'Ú_line__ListÏszAstArcAnalyzer._line__ListcCs*tjjrdS|jr"| |jd¡SdSdS)Nr)r)rrFrGr³rÊ)r$rÂr&r&r'Ú
_line__ModuleÕs
zAstArcAnalyzer._line__ModuleZ	AnnAssignZAssignZAssertZ	AugAssignZDeleteZExprZGlobalZImportZ
ImportFromZNonlocalZPassr«cCsZ|jj}t|d|dƒ}|dk	r(||ƒStjrF||jkrFtd|›ƒ‚t| |¡ƒhSdS)aÆAdd the arcs for `node`.

        Return a set of ArcStarts, exits from this node to the next. Because a
        node represents an entire sub-tree (including its children), the exits
        from a node can be arbitrarily complex::

            if something(1):
                if other(2):
                    doit(3)
                else:
                    doit(5)

        There are two exits from line 1: they start at line 3 and line 5.

        Z	_handle__Nz*** Unhandled: )	r©rtrÁrZTESTINGÚ
OK_TO_DEFAULTÚ	Exceptionr¥rÊ)r$rÂrÃrÉr&r&r'Úadd_arcsäs
zAstArcAnalyzer.add_arcszfrom_start, prev_startscCsŠ|dkr|h}xv|D]n}| |¡}|j ||¡}||jkrX| |¡}|dkrNq| |¡}x|D]}| |j||j¡q^W| |¡}qW|S)auAdd arcs for the body of a compound statement.

        `body` is the body node.  `from_start` is a single `ArcStart` that can
        be the previous line in flow before this body.  `prev_starts` is a set
        of ArcStarts that can be the previous line.  Only one of them should be
        given.

        Returns a set of ArcStarts, the exits from this body.

        N)	rÊr·r;rÚfind_non_missing_noderrYr–r×)r$r³Ú
from_startÚprev_startsZ	body_noderYrJZ
prev_startr&r&r'Ú
add_body_arcss






zAstArcAnalyzer.add_body_arcscCsP| |¡}|j ||¡}||jkr&|St|d|jjdƒ}|rH||ƒ}nd}|S)aSearch `node` looking for a child that has not been optimized away.

        This might return the node you started with, or it will work recursively
        to find a child node in self.statements.

        Returns a node, or None if none of the node remains.

        Z
_missing__N)rÊr·r;rrÁr©rt)r$rÂrYrJZ
missing_fnr&r&r'rØs


z$AstArcAnalyzer.find_non_missing_nodecCs2| t|jƒ¡}|r|S|jr.| t|jƒ¡SdS)N)rØr²r³Úorelse)r$rÂZnon_missingr&r&r'Ú_missing__If>szAstArcAnalyzer._missing__IfcCsTg}x*|jD] }| |¡}|dk	r| |¡qW|s8dSt|ƒdkrL|dSt|ƒS)Nr)r)r³rØrnÚlenr²)r$rÂZnon_missing_childrenÚchildr&r&r'Ú_missing__NodeListIs
z!AstArcAnalyzer._missing__NodeListcCsV| t|jƒ¡}|sdSt ¡}|j|_t ¡|_|j|j_d|j_|j|_d|_	|S)NÚTrue)
rØr²r³r´ZWhilerYÚNameÚtestÚidrÜ)r$rÂZ
body_nodesZ	new_whiler&r&r'Ú_missing__WhileYs

zAstArcAnalyzer._missing__WhilecCs.|jj}|dkrdS|dkr*|jdkr*dSdS)z Is this a compile-time constant?)ZConstantÚNameConstantÚNumrçrâ)ráÚFalseÚNoneÚ	__debug__N)r©rträ)r$rÂrÃr&r&r'Úis_constant_exprgs
zAstArcAnalyzer.is_constant_expr)rŽcCs&x | ¡D]}| ||j¡r
Pq
WdS)z0Add arcs due to jumps from `exits` being breaks.N)rÇrr)r$rŽÚblockr&r&r'rsz"AstArcAnalyzer.process_break_exitscCs&x | ¡D]}| ||j¡r
Pq
WdS)z3Add arcs due to jumps from `exits` being continues.N)rÇr‘r)r$rŽrìr&r&r'r‘ˆsz%AstArcAnalyzer.process_continue_exitscCs&x | ¡D]}| ||j¡r
Pq
WdS)z0Add arcs due to jumps from `exits` being raises.N)rÇr’r)r$rŽrìr&r&r'r’sz"AstArcAnalyzer.process_raise_exitscCs&x | ¡D]}| ||j¡r
Pq
WdS)z1Add arcs due to jumps from `exits` being returns.N)rÇr“r)r$rŽrìr&r&r'r“–sz#AstArcAnalyzer.process_return_exitscCs(| |¡}t|dd}| |g¡tƒS)Nz*the break on line {lineno} wasn't executed)r–)rÊr¥rr)r$rÂÚhereZbreak_startr&r&r'Ú_handle__Break¨s
zAstArcAnalyzer._handle__BreakcCsÎ|j}}|jrÄtjjrd}x8|jD].}| |¡}|dk	rN||krN| ||¡|}q$Wtjjrn| ||¡|}|jrÄ| |jd¡}|j 	||¡}x0t
|d|ƒD]}||jkr¢| ||¡|}q¢Wt|ƒhS)zBAdd arcs for things that can be decorated (classes and functions).Nrr))
rYrÌrrFrËrÊrr³r·r;r@rr¥)r$rÂZ	main_lineÚlastZdec_nodeZ	dec_startZ
body_startrYr&r&r'Ú_handle_decorated¯s(


z AstArcAnalyzer._handle_decoratedcCs(| |¡}t|dd}| |g¡tƒS)Nz-the continue on line {lineno} wasn't executed)r–)rÊr¥r‘r)r$rÂríZcontinue_startr&r&r'Ú_handle__ContinueÎs
z AstArcAnalyzer._handle__ContinuecCs¤| |j¡}|j t|d¡t|dd}|j|j|d}x|D]}| |j	||j
¡q@W|j ¡}|j}t|dd}|j
r–|j|j
|d}||O}n
| |¡|S)N)r*z'the loop on line {lineno} never started)r–)rÙz)the loop on line {lineno} didn't complete)rÊÚiterr¾rnr”r¥rÛr³rrYr–Úpopr•rÜr/)r$rÂr*rÙrŽr—Úmy_blockÚ
else_exitsr&r&r'Ú_handle__ForÕs



zAstArcAnalyzer._handle__ForcCsL| |j¡}t|dd}|j|j|d}t|dd}||j|j|dO}|S)Nz-the condition on line {lineno} was never true)r–)rÙz.the condition on line {lineno} was never false)rÊrãr¥rÛr³rÜ)r$rÂr*rÙrŽr&r&r'Ú_handle__IfîszAstArcAnalyzer._handle__Ifc	CsŠ| |¡}|}tƒ}d}x^|jD]T}| |j¡}t|jtjƒrBd}| ||d¡t|dd}||j	|j
|dO}|}q W|s†| |¡|S)NFTz+the pattern on line {lineno} always matchedz*the pattern on line {lineno} never matched)r–)rÙ)rÊrZcasesÚpatternr¬r´ZMatchAsrr¥rÛr³r/)	r$rÂr*Z
last_startrŽZhad_wildcardZcaseZ
case_startrÙr&r&r'Ú_handle__Match÷s

zAstArcAnalyzer._handle__MatchcCs"| |¡}|j|jt|ƒd}|S)N)rÙ)rÊrÛr³r¥)r$rÂr*rŽr&r&r'Ú_handle__NodeList	s
z AstArcAnalyzer._handle__NodeListcCs(| |¡}t|dd}| |g¡tƒS)Nz*the raise on line {lineno} wasn't executed)r–)rÊr¥r’r)r$rÂríZraise_startr&r&r'Ú_handle__Raises
zAstArcAnalyzer._handle__RaisecCs(| |¡}t|dd}| |g¡tƒS)Nz+the return on line {lineno} wasn't executed)r–)rÊr¥r“r)r$rÂríZreturn_startr&r&r'Ú_handle__Returns
zAstArcAnalyzer._handle__ReturncCsþ|jr| |jd¡}nd}|jr4| |jd¡}nd}|dk	sL|dk	sLt‚t||ƒ}|j |¡| |¡}|j|jt	|ƒd}|jrœd|_
|jr¦tƒ|_n
|j 
¡tƒ}|jrd}xT|jD]J}	| |	¡}|dk	râ| ||¡|}d}
t	||
d}||j|	j|dO}qÀW|jr&|j|j|d}||O}|jrú|j 
¡||jB|jB|jB|jB}|j|j|d}
|jrätjjrÌxD|jD]:}|j}|jj|d}x|
D]}| |j||¡q¤Wq†W|j}n| |j|
¡}| |¡|jr\tjjrDxD|jD]:}|j}|jj|d}x|
D]}| |j||¡qWqþW|j}n| |j|
¡}| |¡|jrx| | |j|
¡¡|jrðtjjrØxD|jD]:}|j}|jj|d}x|
D]}| |j||¡q°Wq’W|j}n| |j|
¡}| |¡|rú|
}|S)Nr)rÙz3the exception caught by line {lineno} didn't happen)r–)rÚ)rY)ÚhandlersrÊZ	finalbodyrr›r¾rnrÛr³r¥rœrr rórrÜržrŸr¡rrFZfinally_jumps_backrYr–rmÚ_combine_finally_startsrr‘r’r“)r$rÂrœrZ	try_blockr*rŽZ
handler_exitsZlast_handler_startZhandler_nodeZ
from_causerÙZ
final_fromZfinal_exitsZ
break_linerYr–Z
final_exitZbreaksZ
continue_lineZ	continuesZreturn_linerÈr&r&r'Ú_handle__TrysŽ














zAstArcAnalyzer._handle__Try)r_rŽrÈcsVg}x0t|ƒD]$}|jdk	r| |jj|jd¡qWd |¡‰‡fdd„|Dƒ}|S)aHelper for building the cause of `finally` branches.

        "finally" clauses might not execute their exits, and the causes could
        be due to a failure to execute any of the exits in the try block. So
        we use the causes from `starts` as the causes for `exits`.
        N)rYz or csh|]}t|jˆƒ’qSr&)r¥rY)rPr—)r–r&r'rQœsz9AstArcAnalyzer._combine_finally_starts.<locals>.<setcomp>)Úsortedr–rnrmrYro)r$r_rŽÚcausesr*r&)r–r'rþs

z&AstArcAnalyzer._combine_finally_startscCsð| |j¡}}| |j¡}d}|r(d}tjjr4d}|rH| |jd¡}|j t	|d¡t
|dd}|j|j|d}x|D]}| |j
||j¡q|Wtƒ}|j ¡}	| |	j¡t
|dd}|jrÞ|j|j|d}
||
O}n|sì| |¡|S)	NFTr)r*z-the condition on line {lineno} was never true)r–)rÙz.the condition on line {lineno} was never false)rÊrãrërrFZkeep_constant_testr³r¾rnr”r¥rÛrrYr–rrór?r•rÜr/)r$rÂr*Zto_topZ
constant_testZtop_is_body0rÙrŽr—rôrõr&r&r'Ú_handle__WhileŸs0



zAstArcAnalyzer._handle__WhilecCsÊ| |¡}tjjr$|j t|d¡|j|jt	|ƒd}tjjrÆ|j 
¡}t	|ƒh}|rxx|D]}| |j|¡q^W|}|j
r’| | |j
|¡¡|jr¬| | |j|¡¡|jrÆ| | |j|¡¡|S)N)r*)rÙ)rÊrrFr£r¾rnr¢rÛr³r¥rórrYržrrþrŸr‘r¡r“)r$rÂr*rŽZ
with_blockZ	with_exitr—r&r&r'Ú
_handle__With¼s*



zAstArcAnalyzer._handle__WithcCsl| |¡}|jrL|j|jt|ƒd}x@|D]}| |j||jd¡q,Wn| ||¡| ||¡dS)N)rÙzdidn't exit the module)rÊr³rÛr¥rrYr–)r$rÂr*rŽr—r&r&r'Ú_code_object__ModuleÞs

z#AstArcAnalyzer._code_object__ModulecCsN| |¡}|j t||jd¡|j|jt|ƒd}| |¡|j 	¡dS)N)r*r™)rÙ)
rÊr¾rnr˜r™rÛr³r¥r“ró)r$rÂr*rŽr&r&r'Ú_code_object__FunctionDefés


z(AstArcAnalyzer._code_object__FunctionDefcCs\| |¡}| ||¡|j|jt|ƒd}x*|D]"}| |j||jd|j›¡q2WdS)N)rÙzdidn't exit the body of class )rÊrrÛr³r¥rYr–r™)r$rÂr*rŽr—r&r&r'Ú_code_object__ClassDefòs

z%AstArcAnalyzer._code_object__ClassDefcs‡fdd„}|S)zPA function to make methods for expression-based callable _code_object__ methods.c	sJ| |¡}| ||ddˆ›d|›¡| ||ddˆ›d|›¡dS)Nzdidn't run the z	 on line zdidn't finish the )rÊr)r$rÂr*)Únounr&r'Ú!_code_object__expression_callableþs
zVAstArcAnalyzer._make_expression_code_method.<locals>._code_object__expression_callabler&)rrr&)rr'Ú_make_expression_code_methodüsz+AstArcAnalyzer._make_expression_code_methodÚlambdazgenerator expressionzdictionary comprehensionzset comprehensionzlist comprehension)NN)NN)=rtrurvrwrrr(rcrirrÇrÊrÍrÏZ_line__ClassDefrÒZ_line__FunctionDefZ_line__AsyncFunctionDefrÓrÔrÕr×rrÛrØrÝràrårërr‘r’r“rîrðZ_handle__ClassDefrñröZ_handle__AsyncForZ_handle__FunctionDefZ_handle__AsyncFunctionDefr÷rùrúrûrürÿrþrrZ_handle__AsyncWithrrZ_code_object__AsyncFunctionDefrr	Z_code_object__LambdaZ_code_object__GeneratorExpZ_code_object__DictCompZ_code_object__SetCompZ_code_object__ListCompr&r&r&r'rbist

	p
rbÚctxcCs&|dgditƒgkp$t|ttttfƒS)z:Is `value` simple enough to be displayed on a single line?Nr&)rr¬ÚbytesriÚfloatrš)rÎr&r&r'Ú_is_simple_valuesrc
CsÚd|}t|ddƒ}|dk	rld|j›d|j›}t|dƒrp|d7}|j|jkr^||j›d7}||j›7}nd}|›d	|jj›|›}d
d„t 	|¡Dƒ}|s°||›dƒn&t
|ƒd
krôt|dd
ƒrô|d\}}	||›d|›d|	›dƒnâ||ƒ|d}
xÂ|D]º\}}	|
›|›d}t|	ƒr>||›d|	›ƒn„t|	t
ƒr¨||›dƒx>|	D]6}t|ƒr€||
›d|›ƒnt||d|dq^W||
›dƒn||ƒt|	|d|dq
W||›dƒdS)z`Dump the AST for `node`.

    This recursively walks the AST, printing a readable version.

    rkrYNz @ ú,Ú
end_linenor4Úú<cSs g|]\}}|tkr||f‘qSr&)ÚSKIP_DUMP_FIELDS)rPr™rÎr&r&r'rV*szast_dump.<locals>.<listcomp>ú>r)rz: z    z [é)r8ú])rÁrYÚ
col_offsetr\rZend_col_offsetr©rtr´Úiter_fieldsrÞrr¬r½r¼)
rÂÚdepthr8rIrYZlinemarkÚheadZnamed_fieldsÚ
field_namerÎZnext_indentÚprefixÚnr&r&r'r¼sD



r¼)+rwr´rgrºr+r6r9ZcoveragerZcoverage.bytecoderZcoverage.debugrZcoverage.exceptionsrrrZ
coverage.miscrr	r
rrZcoverage.phystokensr
rrrrDrr”r˜r›r¢Ú
namedtupler¥r²r¶rbrrr8r¼r&r&r&r'Ú<module>sD>Q,&)