qBFj  dddlZddlZddlZddlmZmZmZddlmZmZddl m Z m Z m Z m Z mZmZmZmZddlmZedZedZdefd Zd e ed e efd Zd edejd e eeffdZde ed e e eeffdZded efdZeeddZdeeefd efdZdeeefd e eeeffdZ deeefd e eeffdZ!de edeegefd eee effdZ"Gdde#Z$dZ%d#d!Z&d"Z'dS)$N) OrderedDictCounter defaultdict) FrameType TracebackType)IteratorListTupleIterableCallableUnionTypeVarMapping)ASTTextTR max_lengthct||krC|t|z dz}|t|z |z }|d||z|| dz}|S)N)len)seqrmiddlerightlefts >C:\PYTHON\_runtimes\venv\Lib\site-packages\stack_data/utils.pytruncatersc 3xx*c&kk)a/CKK'%/%4%j6!CL0 JitreturncDttj|SN)listrfromkeys)rs runique_in_orderr$s  $R(( ) ))ratoknodec t|ttddr:t||j\}}t||jd\}}||fS||d\\}}\}}||dzfS)z Returns a pair of numbers representing a half open range (i.e. suitable as arguments to the `range()` builtin) of line numbers of the given AST nodes. match_caseF)padded) isinstancegetattrast line_rangepatternbodyget_text_positions)r%r&start_end_startend_s rr0r0s $\26677 t|44 t ty}55 cz#66tE6JJ HS!cAg~rlstc#Kt|tj|fdD]\}|rjtdgt zfd}t D]2|fd|fd|fd3ntjdtEd{VdS) Nc|dkS)Nr))xcountss rz"highlight_unique../sQrkeyFcL |}n#t$rYdSwxYwd|<|S)NT) ValueError)fi highlighteds rhighlight_indexz)highlight_unique..highlight_index4sE AA!   44 !% As  c.Sr!indexgroupitemsrr?z"highlight_unique..=s D0A0Arc6dzSNr,rI)firstrLrMsrr?z"highlight_unique..?sEKKeai,H,HrcFddddz S)Nr*rIrKsrr?z"highlight_unique..@s$U44R4[->->t-D-D(DrT)r itertoolsgroupbyr"rsetrepeatzip)r9 is_commonrGr>rPrLrFrMs @@@@@rhighlight_uniquerX,sD S\\F%-c7N7N7N7NOOO++ 5  1KKE 'CJJ.K     E  F F'(A(A(A(A(ABB$#O$H$H$H$H$H$HIII D D D D DEEEE  F $*400Kuk**********+++rr=c|Sr!r))r=s ridentityrZGs Hr)mapperrAc#fKtt||}tjt |t |dD]^\}}t |\}}|rt||Ed{V*t |\} } |t|t| V_dS)Nc|ddSrOr))ts rr?z#collapse_repeated..Os!A$q'rr@)r"maprRrSrVrX) r9 collapserr[rAkeyedis_highlightedrLoriginal_grouphighlighted_group keyed_groupr8s rcollapse_repeatedrfKs S#  E!*!2 %e,, - -!!""" E E-0K))  E6>22 2 2 2 2 2 2 2 2 "34NK)D00${2C2CDD D D D D E Er frame_or_tbctt|tjtjft|tjfSr!)assert_r-typesrrrgs ris_framerlYs9 J{U_e6I$J K KLLL kEO#5 6 66rc#^K|}|r&|Vt|r|j}n|j}|$dSdSr!)rlf_backtb_next)rgcurrents r iter_stackrq^sZ5@G & G   &nGGoG &&&&&rcNt|r ||jfS|j|jfSr!)rlf_linenotb_frame tb_linenorks rframe_and_linenorvhs1 ;K000#[%:::riterablekey_funcctt}|D]&}||||'|S)a Create a dictionary from an iterable such that the keys are the result of evaluating a key function on elements of the iterable and the values are lists of elements all of which correspond to the key. >>> def si(d): return sorted(d.items()) >>> si(group_by_key_func("a bb ccc d ee fff".split(), len)) [(1, ['a', 'd']), (2, ['bb', 'ee']), (3, ['ccc', 'fff'])] >>> si(group_by_key_func([-1, 0, 1, 3, 6, 8, 9, 2], lambda x: x % 2)) [(0, [0, 6, 8, 2]), (1, [-1, 1, 3, 9])] )rr"append)rwrxresultrMs rgroup_by_key_funcr|osI  F,,xx~~%%d++++ Mrc"eZdZdZdZdZeZdS)cached_propertyz A property that is only computed once per instance and then replaces itself with an ordinary attribute. Deleting the attribute resets the property. Based on https://github.com/pydanny/cached-property/blob/master/cached_property.py c,|j|_||_dSr!)__doc__func)selfrs r__init__zcached_property.__init__s|  rc`||S||x}|j|jj<|Sr!)r__dict____name__)robj_clsvalues rcached_property_wrapperz'cached_property.cached_property_wrappers1 ;K3799S>>A TY/0 rN)r __module__ __qualname__rrr__get__r)rrr~r~s=&GGGrr~c ddl}ddlm}Gfddt|d}|d} ||||}n#t $r|}YnwxYw|S)Nr)get_lexer_by_namec"eZdZfdZxZS)'_pygmented_with_ranges..MyLexerc3Kdt|D]?\}}tfdDr|j}t |z ||fV@dS)Nrc3>K|]\}}|cxko|kncVdSr!r)).0r4r7lengths r zE_pygmented_with_ranges..MyLexer.get_tokens..sCFFu,,,,,,,,FFFFFFr)super get_tokensany ExecutingNoder)rtextttyperr __class__rangess @rrz2_pygmented_with_ranges..MyLexer.get_tokenssF % 2 24 8 8 # # uFFFFvFFFFF0!/E#e**$Ul""""  # #r)rrrr __classcell__)rrs@rMyLexerrs> # # # # # # # # # #rrpython3F)stripnl)pygmentspygments.lexersrtype highlight Exception splitlines) formattercoderrrrlexerrFs ` r_pygmented_with_rangesrsOOO111111#######$((3344### GE " " "E((ui@@    ! ! # ##sA A&%A&cV|s&t|trt|}|dSr!)r-strAssertionError) conditionerrors rriris8  eS ! ! *"5))E rc^ t|S#dt|jzcYSxYw)Nz)rrr)rs rsome_strrs8@5zz@(4;;+?????s,)r)(r/rRrj collectionsrrrrrtypingrr r r r r rr asttokensrrrintrr$ASTr0boolrXrZrfrlrqrvr|objectr~rrirr)rrrs0  9999999999********  GCLL GCLLc* *Q**** W CG c3h    +$q'+huQW~&>++++6  a    19h E E E E E7% = 897d7777 &E)]":;&yZgOgIh@i&&&&;% =(@"A;eIWZNF[;;;; xQ7GGTUW[\]W^T^L_$&&&&&f&&&,$$$,@@@@@r