GIF89a=( õ' 7IAXKgNgYvYx\%wh…hŽth%ˆs%—x¨}9®Œ©€&©‰%¶†(¹–.¹5·œD¹&Çš)ÇŸ5ǘ;Í£*È¡&Õ²)ׯ7×µ<Ñ»4ï°3ø‘HÖ§KͯT÷¨Yÿšqÿ»qÿÔFØ !ù ' !ÿ NETSCAPE2.0 , =( þÀ“pH,È¤rÉl:ŸÐ¨tJ­Z¯Ø¬vËíz¿à°xL.›Ïè´zÍn»ßð¸|N¯Ûïø¼~Ïïûÿ€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§gª«ªE¯°¨¬ª±²Œ¹º¹E¾­”´ÂB¶¯ §Åȸ»ÑD¾¿Á•ÄÅ®° ÝH¾ÒLÀÆDÙ«D¶BÝïðÀ¾DÑÑÔTÌÍíH òGö¨A RÎڐ |¥ ٭&ºìE8œ¹kGÔAÞpx­a¶­ã R2XB®åE8I€Õ6Xî:vT)äžþÀq¦è³¥ì仕F~%xñ  4#ZÔ‰O|-4Bs‘X:= QÉ œš lºÒyXJŠGȦ|s hÏíK–3l7·B|¥$'7Jީܪ‰‡àá”Dæn=Pƒ ¤Òëí‰`䌨ljóá¯Éüv>á–Á¼5 ½.69ûϸd«­ºÀûnlv©‹ªîf{¬ÜãPbŸ  l5‘ޝpß ´ ˜3aÅùäI«O’ý·‘áÞ‡˜¾Æ‚ÙÏiÇÿ‹Àƒ #öó)pâš Þ½ ‘Ý{ó)vmÞü%D~ 6f s}ŃƒDØW Eþ`‡þ À…L8xá†ç˜{)x`X/> Ì}mø‚–RØ‘*|`D=‚Ø_ ^ð5 !_…'aä“OÚ—7âcð`D”Cx`ÝÂ¥ä‹éY¹—F¼¤¥Š?¡Õ™ n@`} lď’ÄÉ@4>ñd œ à‘vÒxNÃ×™@žd=ˆgsžG±æ ´²æud &p8Qñ)ˆ«lXD©øÜéAžHìySun jª×k*D¤LH] †¦§C™Jä–´Xb~ʪwStŽ6K,°£qÁœ:9ت:¨þªl¨@¡`‚ûÚ ».Û¬¯t‹ÆSÉ[:°=Š‹„‘Nåû”Ìî{¿ÂA ‡Rà›ÀÙ6úë°Ÿð0Ä_ ½;ÃϱîÉì^ÇÛÇ#Ëë¼ôº!±Ä˜íUîÅÇ;0L1óÁµö«p% AÀºU̬ݵ¼á%霼€‡¯Á~`ÏG¯»À× ­²± =4ªnpð3¾¤³¯­ü¾¦îuÙuµÙ®|%2ÊIÿür¦#0·ÔJ``8È@S@5ê¢ ö×Þ^`8EÜ]ý.뜃Âç 7 ú ȉÞj œ½Dç zý¸iþœÑÙûÄë!ˆÞÀl§Ïw‹*DçI€nEX¯¬¼ &A¬Go¼QföõFç°¯;é¦÷îŽêJ°îúôF5¡ÌQ|îúöXªæ»TÁÏyñêï]ê² o óÎC=öõ›ÒÓPB@ D×½œä(>èCÂxŽ`±«Ÿ–JЀ»Û á¤±p+eE0`ëŽ`A Ú/NE€Ø†À9‚@¤à H½7”à‡%B‰`Àl*ƒó‘–‡8 2ñ%¸ —€:Ù1Á‰E¸àux%nP1ð!‘ðC)¾P81lÑɸF#ˆ€{´âé°ÈB„0>±û °b¡Š´±O‚3È–Ù()yRpbµ¨E.Z‘D8ÊH@% òŒx+%Ù˜Æcü »¸˜fõ¬b·d`Fê™8èXH"ÉÈ-±|1Ô6iI, 2““¬$+](A*jÐ QTÂo‰.ÛU슬Œã„Ž`¯SN¡–¶Äåyše¯ª’­¬‚´b¦Éož œ)åyâ@Ì®3 ÎtT̉°&Ø+žLÀf"Ø-|žçÔ>‡Ðv¦Ðžì\‚ Q1)Ž@Žh#aP72”ˆ™¨$‚ !ù " , =( …7IAXG]KgNgYvYxR"k\%w]'}hŽth%ˆg+ˆs%—r.—m3šx3˜x¨}9®€&©€+¨‡7§‰%¶†(¹–.¹œD¹&ǘ;Í•&ײ)×»4ïÌ6ò§KÍ þ@‘pH,È¤rÉl:ŸÐ¨tJ­Z¯Ø¬vËíz¿à°xL.›Ïè´zÍn»ßð¸|N¯Ûïø¼~Ïïûÿ€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§g «¬ E ±± ¨­¶°ººE Á´”·®C¬²§Ç¶Œ»ÓDÃÕƷ¯Ê±H½ºM×ÁGÚ¬D¶BËÁ½î½DÓôTÏÛßîG»ôõC×CÌ l&âž:'òtU³6ɹ#·Ø)€'Ü.6±&ëÍÈ» K(8p0N?!æ2"ÛˆNIJX>R¼ÐO‚M '¡¨2¸*Ÿþ>#n↠å@‚<[:¡Iïf’ ¤TÚ˘CdbÜÙ“[«ŽEú5MBo¤×@€`@„€Êt W-3 ¶Ÿ¡BíêäjIÝ…Eò9[T…$íêﯧ„…•s»Óȳ¹€ÅÚdc®UUρ#±Ùïldj?´í¼²`\ŽÁðÞu|3'ÖŒ]ë6 ¶S#²‡˜FKLÈ *N E´‘áäŠ$˜›eÄYD„ºq«.è촁ƒs \-ÔjA 9²õ÷å- üúM[Âx(ís÷ì®x€|í¡Ù’p¦‚ ŽkÛTÇDpE@WÜ ²Ç]kŠ1¨ þ€·Yb ÓÁ‰l°*n0 ç™—žzBdОu¾7ĉBl€â‰-ºx~|UåU‰  h*Hœ|e"#"?vpÄiŠe6^ˆ„+qâŠm8 #VÇá ‘å–ÄV„œ|Аè•m"сœn|@›U¶ÆÎž—Špb¥G¨ED”€±Úê2FÌIç? >Éxå Œ± ¡¤„%‘žjŸ‘ꄯ<Ìaà9ijÐ2˜D¦È&›†Z`‚å]wþ¼Â:ç6àB¤7eFJ|õÒ§Õ,¨äàFÇ®cS·Ê¶+B°,‘Þ˜ºNûãØ>PADÌHD¹æž«ÄÀnÌ¥}­#Ë’ë QÀÉSÌÂÇ2ÌXÀ{æk²lQÁ2«ÊðÀ¯w|2Í h‹ÄÂG€,m¾¶ë3ÐÙ6-´ÅE¬L°ÆIij*K½ÀÇqï`DwVÍQXœÚÔpeœ±¬Ñ q˜§Tœ½µƒ°Œìu Â<¶aØ*At¯lmEØ ü ôÛN[P1ÔÛ¦­±$ÜÆ@`ùåDpy¶yXvCAyåB`ŽD¶ 0QwG#¯ æš[^Äþ $ÀÓÝǦ{„L™[±úKÄgÌ;ï£S~¹ìGX.ôgoT.»åˆ°ùŸûù¡?1zö¦Ÿž:ÅgÁ|ìL¹ „®£œŠ‚à0œ]PÁ^p F<"•ç?!,ñ‡N4—…PÄ Á„ö¨Û:Tè@hÀ‹%táÿ:ø-žI<`þ‹p I….)^ 40D#p@ƒj4–؀:²‰1Øâr˜¼F2oW¼#Z†;$Q q” ‘ ÂK¦ñNl#29 !’F@¥Bh·ᏀL!—XFóLH‘Kh¤.«hE&JòG¨¥<™WN!€ÑÙÚˆY„@†>Œž19J" 2,/ &.GXB%ÌRÈ9B6¹W]’î×ÔW¥’IÎ$ ñ‹ÓŒE8YÆ ¼³™ñA5“à®Q.aŸB€&Ø©³ JÁ—! ¦t)K%tœ-¦JF bòNMxLôþ)ÐR¸Ð™‘ èÝ6‘O!THÌ„HÛ ‰ !ù ) , =( …AXKgNgYvYxR"k\%wh…hŽh%ˆg+ˆs%—r.—x3˜x¨}9®€&©€+¨Œ,©‡7§‰%¶†(¹–.¹5·&Çš)ǘ;Í•&×£*Ȳ)ׯ7×»4ï°3øÌ6ò‘HÖ§KÍ»Hó¯T÷¨Yÿ»qÿÇhÿ þÀ”pH,È¤rÉl:ŸÐ¨tJ­Z¯Ø¬vËíz¿à°xL.›Ïè´zÍn»ßð¸|N¯Ûïø¼~Ïïûÿ€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§g ª« E$±²¨ª­ · °²½$E$ÂÕ««D· Í ¿¦Ç¶¸ÌŒ¾³CÃÅÆ E ééH½MÛÂGâªD­ çBêêϾD²ÒaÀà€Š1r­ðÓ¤ ÔožzU!L˜C'¾yW½UGtäÇïÙllê0×àÂuGþ)AÀs[þ·xì ÁxO%ƒûX2ó—  P£n›R/¡ÑšHše+êDm?# —‘Ç£6¡8íJ¡ŸâDiäªM¥Ö„ôj“¬¹£5oQ7°- <‡ *´lãÓŒ2r/a!l)dÈ A™ÈE¢ôÔ͆…ð ;Ö˜c ¡%ß‚’Ùˆâ¸b½—pe~C"BíëÚHïeF2§æŠ8qb t_`urŠeü wÅu3êæPv§h•"ß`íÍxçLĹÜÖ3á  ~Öº“®›¸ÏMDfJÙ °„ÛµáWõ%§œ‚à©–‚X ÓØ)@®Ñ›Eþ´wëuÅSxb8y\mÖzœ¥§ZbºE—ÂLªÌw!y(>¡™wú=Ç|ÅÝs¢d €CÁW)HÜcC$€L Ä7„r.á\{)@ð` @ äXÈ$PD” `šaG:§æˆOˆ72EÐamn]ù"ŒcÊxÑŒ° &dR8`g«iÙŸLR!¦P …d’ä¡“¦ðÎTƒ¦ià|À _ ¥ Qi#¦Šg›Æ ›noMµ ›V ã£)p ç£ÎW…š=Âeªk§†j„ ´®1ß²sÉxéW«jšl|0¯B0Û, \jÛ´›6±¬¶C ÛíWþï|ëÙ‹¸ñzĸV {ì;Ýñn¼òVˆm³I¼³.Ðã¤PN¥ ²µ¼„µCã+¹ÍByî£Ñ¾HŸ›ëê 7ìYÆFTk¨SaoaY$Dµœìï¿Ã29RÈkt Çïfñ ÇÒ:ÀÐSp¹3ÇI¨â¥DZÄ ü9Ïýögñ½­uÔ*3)O‘˜Ö[_hv ,àî×Et Ÿé¶BH€ Õ[ü±64M@ÔSÌM7dÐl5-ÄÙU܍´©zߌ3Ô€3ž„ „ ¶ÛPô½5×g› êÚ˜kN„Ý…0Îj4€Ìë°“#{þÕ3S2çKÜ'ợlø¼Ú2K{° {Û¶?žm𸧠ËI¼nEò='êüóºè^üæÃ_Û=°óž‚ì#Oý¿Í'¡½áo..ÏYìnüñCœO±Áa¿¢Kô½o,üÄËbö²çºíï{ËC Ú— "”Ï{ËK ÍÒw„õ±Oz dÕ¨à:$ ƒô—«v»] A#ð «€¿šéz)Rx׿ˆ¥‚d``èw-îyÏf×K!ð€þ­Ð|ìPľ„=Ì`ý(f” 'Pa ¥ÐBJa%Ðâf§„%Š¡}FàáÝ×6>ÉäŠG"éŽè=ø!oа^FP¼Ø©Q„ÀCÙÁ`(Ž\ÄÝ® ©Â$<n@dÄ E#ììUÒI! ‚#lù‹`k¦ÐÇ'Rró’ZýNBÈMF Í[¤+‹ðɈ-áwj¨¥þ8¾rá ,VÂh„"|½œ=×G_¦Ñ™EØ 0i*%̲˜Æda0mV‚k¾)›;„&6 p>ÓjK “¦Ç# âDÂ:ûc?:R Ó¬fÞéI-Ì“•Ã<ä=™Ï7˜3œ¨˜c2ŒW ,ˆ”8(T™P‰F¡Jhç"‚ ; 403WebShell
403Webshell
Server IP : 104.21.83.152  /  Your IP : 216.73.216.195
Web Server : LiteSpeed
System : Linux premium229.web-hosting.com 4.18.0-553.45.1.lve.el8.x86_64 #1 SMP Wed Mar 26 12:08:09 UTC 2025 x86_64
User : akhalid ( 749)
PHP Version : 8.3.22
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /lib64/python3.6/lib2to3/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib64/python3.6/lib2to3/__pycache__/refactor.cpython-36.opt-1.pyc
3


 \=m�@s<dZdZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mZmZm
Z
ddlmZddlmZmZdd	lmZd&dd�ZGd
d�de�Zdd�Zdd�Zdd�Zdd�Zejd'kr�ddlZejZdd�Z dd�Z!neZeZ eZ!dd�Z"Gdd�de�Z#Gd d!�d!e$�Z%Gd"d#�d#e�Z&Gd$d%�d%e%�Z'dS)(z�Refactoring framework.

Used as a main program, this can refactor any number of files and/or
recursively descend down directories.  Imported as a module, this
provides infrastructure to write your own refactoring tool.
z#Guido van Rossum <[email protected]>�N)�chain�)�driver�tokenize�token)�	find_root)�pytree�pygram)�btm_matcherTcCstt|ggdg�}tjj|j�}g}xLttj|��D]:}|jd�r2|jd�r2|rZ|dd�}|j	|dd��q2W|S)zEReturn a sorted list of all available fix names in the given package.�*�fix_z.py�N����)
�
__import__�os�path�dirname�__file__�sorted�listdir�
startswith�endswith�append)Z	fixer_pkgZ
remove_prefixZpkgZ	fixer_dirZ	fix_names�name�r�(/usr/lib64/python3.6/lib2to3/refactor.py�get_all_fix_namessrc@seZdZdS)�
_EveryNodeN)�__name__�
__module__�__qualname__rrrrr+srcCs�t|tjtjf�r(|jdkr t�|jhSt|tj�rH|jrDt|j�St�t|tj	�r�t
�}x*|jD] }x|D]}|jt|��qlWqbW|Std|��dS)zf Accepts a pytree Pattern Node and returns a set
        of the pattern types which will match first. Nz$Oh no! I don't understand pattern %s)
�
isinstancerZNodePatternZLeafPattern�typerZNegatedPatternZcontent�_get_head_typesZWildcardPattern�set�update�	Exception)Zpat�r�p�xrrrr$/s


r$cCs�tjt�}g}x�|D]|}|jrjyt|j�}Wntk
rJ|j|�Yq�XxB|D]}||j|�qRWq|jdk	r�||jj|�q|j|�qWx,tt	j
jj�t	j
j
�D]}||j|�q�Wt|�S)z^ Accepts a list of fixers and returns a dictionary
        of head node type --> fixer list.  N)�collections�defaultdict�list�patternr$rrZ_accept_typerr	�python_grammarZ
symbol2number�values�tokens�extend�dict)Z
fixer_listZ
head_nodesZevery�fixerZheadsZ	node_typerrr�_get_headnode_dictKs"



r5cs�fdd�t�d�D�S)zN
    Return the fully qualified names for fixers in the package pkg_name.
    csg|]}�d|�qS)�.r)�.0�fix_name)�pkg_namerr�
<listcomp>hsz+get_fixers_from_package.<locals>.<listcomp>F)r)r9r)r9r�get_fixers_from_packageds
r;cCs|S)Nr)�objrrr�	_identityksr=rcCs|jdd�S)Nz
�
)�replace)�inputrrr�_from_system_newlinesrsrAcCs tjdkr|jdtj�S|SdS)Nr>)r�linesepr?)r@rrr�_to_system_newlinests
rCcsTd}tjtj|�j���fdd�}ttjtjtj	h�}t
�}y�x�|�\}}||krVq@q@|tjkrl|rfPd}q@|tjko||dk�r,|�\}}|tjks�|dkr�P|�\}}|tjks�|dkr�P|�\}}|tj
kr�|dkr�|�\}}xJ|tjk�r(|j|�|�\}}|tj
k�s|d	k�rP|�\}}q�Wq@Pq@WWntk
�rJYnXt|�S)
NFcst��}|d|dfS)Nrr)�next)�tok)�genrr�advance�sz(_detect_future_features.<locals>.advanceT�fromZ
__future__�import�(�,)r�generate_tokens�io�StringIO�readline�	frozensetr�NEWLINE�NL�COMMENTr%�STRING�NAME�OP�add�
StopIteration)�sourceZhave_docstringrG�ignore�features�tp�valuer)rFr�_detect_future_featuressD








r^c@seZdZdZdS)�
FixerErrorzA fixer could not be loaded.N)rr r!�__doc__rrrrr_�sr_c@s�eZdZddd�ZdZdZd4dd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zd5dd�Zd6dd�Z
dd�Zd7dd�Zdd�Zd8dd�Zdd�Zd d!�Zd9d"d#�Zd:d$d%�Zd&Zd'Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�ZdS);�RefactoringToolF)�print_function�write_unchanged_filesZFixrNcCs2||_|pg|_|jj�|_|dk	r0|jj|�|jdrDtj|_ntj	|_|jj
d�|_g|_t
jd�|_g|_d|_tj|jtj|jd�|_|j�\|_|_g|_tj�|_g|_g|_xXt|j|j�D]F}|j r�|jj!|�q�||jkr�|jj"|�q�||jkr�|jj"|�q�Wt#|j�|_$t#|j�|_%dS)z�Initializer.

        Args:
            fixer_names: a list of fixers to import
            options: a dict with configuration.
            explicit: a list of fixers to run even if they are explicit.
        NrbrcraF)�convert�logger)&�fixers�explicit�_default_options�copy�optionsr&r	�!python_grammar_no_print_statement�grammarr/�getrc�errors�loggingZ	getLoggerre�	fixer_log�wroterZDriverrrd�
get_fixers�	pre_order�
post_order�files�bmZ
BottomMatcher�BMZ
bmi_pre_orderZbmi_post_orderrZ
BM_compatibleZ	add_fixerrr5�bmi_pre_order_heads�bmi_post_order_heads)�selfZfixer_namesrjrgr4rrr�__init__�s<





zRefactoringTool.__init__cCs\g}g}�x&|jD�]}t|iidg�}|jdd�d}|j|j�rV|t|j�d�}|jd�}|jdjdd�|D��}yt	||�}Wn$t
k
r�td	||f��YnX||j|j
�}	|	jr�|jd
k	r�||jkr�|jd|�q|jd|�|	jd
k�r|j|	�q|	jdk�r |j|	�qtd|	j��qWtjd�}
|j|
d�|j|
d�||fS)aInspects the options to load the requested patterns and handlers.

        Returns:
          (pre_order, post_order), where pre_order is the list of fixers that
          want a pre-order AST traversal, and post_order is the list that want
          post-order traversal.
        rr6rN�_�cSsg|]}|j��qSr)�title)r7r)rrrr:�sz.RefactoringTool.get_fixers.<locals>.<listcomp>zCan't find %s.%sTzSkipping optional fixer: %szAdding transformation: %sZpreZpostzIllegal fixer order: %rZ	run_order)�key���)rfr�rsplitr�FILE_PREFIX�len�split�CLASS_PREFIX�join�getattr�AttributeErrorr_rjrprg�log_message�	log_debug�orderr�operator�
attrgetter�sort)rzZpre_order_fixersZpost_order_fixersZfix_mod_path�modr8�parts�
class_nameZ	fix_classr4Zkey_funcrrrrr�s8


zRefactoringTool.get_fixerscOs�dS)zCalled when an error occurs.Nr)rz�msg�args�kwdsrrr�	log_errorszRefactoringTool.log_errorcGs|r||}|jj|�dS)zHook to log a message.N)re�info)rzr�r�rrrr�szRefactoringTool.log_messagecGs|r||}|jj|�dS)N)re�debug)rzr�r�rrrr�szRefactoringTool.log_debugcCsdS)zTCalled with the old version, new version, and filename of a
        refactored file.Nr)rz�old_text�new_text�filename�equalrrr�print_outputszRefactoringTool.print_outputcCs<x6|D].}tjj|�r&|j|||�q|j|||�qWdS)z)Refactor a list of files and directories.N)rr�isdir�refactor_dir�
refactor_file)rz�items�write�
doctests_onlyZdir_or_filerrr�refactor#s
zRefactoringTool.refactorc
Cs�tjd}x�tj|�D]�\}}}|jd|�|j�|j�xH|D]@}|jd�rBtjj|�d|krBtjj||�}	|j	|	||�qBWdd�|D�|dd�<qWdS)z�Descends down a directory and refactor every Python file found.

        Python files are assumed to have a .py extension.

        Files and subdirectories starting with '.' are skipped.
        �pyzDescending into %sr6rcSsg|]}|jd�s|�qS)r6)r)r7Zdnrrrr:>sz0RefactoringTool.refactor_dir.<locals>.<listcomp>N)
r�extsep�walkr�r�rr�splitextr�r�)
rzZdir_namer�r�Zpy_ext�dirpathZdirnames�	filenamesr�fullnamerrrr�,s

zRefactoringTool.refactor_dircCs�yt|d�}Wn.tk
r<}z|jd||�dSd}~XnXztj|j�d}Wd|j�Xt|d|d��}t|j	��|fSQRXdS)zG
        Do our best to decode a Python source file correctly.
        �rbzCan't open %s: %sNrr()�encoding)NN)
�open�OSErrorr�r�detect_encodingrO�close�_open_with_encodingrA�read)rzr��f�errr�rrr�_read_python_source@s
z#RefactoringTool._read_python_sourcecCs�|j|�\}}|dkrdS|d7}|rn|jd|�|j||�}|jsL||kr`|j|||||�q�|jd|�nH|j||�}|js�|r�|jr�|jt|�dd�|||d�n|jd|�dS)	zRefactors a file.Nr>zRefactoring doctests in %szNo doctest changes in %sr)r�r�zNo changes in %sr�)r�r��refactor_docstringrc�processed_file�refactor_string�was_changed�str)rzr�r�r�r@r��output�treerrrr�PszRefactoringTool.refactor_filecCs�t|�}d|krtj|j_zJy|jj|�}Wn4tk
r`}z|jd||jj	|�dSd}~XnXWd|j|j_X||_
|jd|�|j||�|S)aFRefactor a given input string.

        Args:
            data: a string holding the code to be refactored.
            name: a human-readable name for use in error/log messages.

        Returns:
            An AST corresponding to the refactored input stream; None if
            there were errors during the parse.
        rbzCan't parse %s: %s: %sNzRefactoring %s)
r^r	rkrrlZparse_stringr'r��	__class__r�future_featuresr��
refactor_tree)rz�datarr[r�r�rrrr�gs
zRefactoringTool.refactor_stringcCs�tjj�}|rN|jd�|j|d�}|js2||krB|j|d|�q�|jd�n:|j|d�}|jsj|r~|jr~|jt	|�d|�n
|jd�dS)NzRefactoring doctests in stdinz<stdin>zNo doctest changes in stdinzNo changes in stdin)
�sys�stdinr�r�r�rcr�r�r�r�)rzr�r@r�r�rrr�refactor_stdin�s

zRefactoringTool.refactor_stdinc
Cs�x"t|j|j�D]}|j||�qW|j|j|j��|j|j|j��|jj|j	��}�xvt
|j���rАx`|jjD�]R}||ko�||rv||j
tjjdd�|jr�||j
tjjd��x
t||�D�]�}|||kr�||j|�yt|�Wntk
�rw�YnX|j�r(||jk�r(q�|j|�}|r�|j||�}|dk	r�|j|�x,|j�D] }|j�spg|_|jj|��q^W|jj|j	��}x2|D]*}	|	|k�r�g||	<||	j||	��q�Wq�WqvWq\Wx$t|j|j�D]}|j||��q�W|jS)a�Refactors a parse tree (modifying the tree in place).

        For compatible patterns the bottom matcher module is
        used. Otherwise the tree is traversed node-to-node for
        matches.

        Args:
            tree: a pytree.Node instance representing the root of the tree
                  to be refactored.
            name: a human-readable name for this tree.

        Returns:
            True if the tree was modified, False otherwise.
        T)r�reverse)rN)rrsrtZ
start_tree�traverse_byrxryrwZrunZleaves�anyr0rfr�rZBaseZdepthZkeep_line_orderZ
get_linenor-�remover�
ValueErrorZfixers_applied�match�	transformr?rr2Zfinish_treer�)
rzr�rr4Z	match_set�node�results�newZnew_matchesZfxrrrrr��sJ



$zRefactoringTool.refactor_treecCs^|sdSxP|D]H}xB||jD]4}|j|�}|r|j||�}|dk	r|j|�|}qWqWdS)aTraverse an AST, applying a set of fixers to each node.

        This is a helper method for refactor_tree().

        Args:
            fixers: a list of fixer instances.
            traversal: a generator that yields AST nodes.

        Returns:
            None
        N)r#r�r�r?)rzrfZ	traversalr�r4r�r�rrrr��s


zRefactoringTool.traverse_bycCs�|jj|�|dkr.|j|�d}|dkr.dS||k}|j||||�|r`|jd|�|js`dS|rv|j||||�n|jd|�dS)zR
        Called when a file has been refactored and there may be changes.
        NrzNo changes to %szNot writing changes to %s)rurr�r�r�rc�
write_file)rzr�r�r�r�r�r�rrrr��szRefactoringTool.processed_filec%Cs�yt|d|d�}Wn.tk
r@}z|jd||�dSd}~XnXzHy|jt|��Wn0tk
r�}z|jd||�WYdd}~XnXWd|j�X|jd|�d|_dS)z�Writes a string to a file.

        It first shows a unified diff between the old text and the new text, and
        then rewrites the file; the latter is only done if the write option is
        set.
        �w)r�zCan't create %s: %sNzCan't write %s: %szWrote changes to %sT)r�r�r�r�rCr�r�rq)rzr�r�r�r�r�r�rrrr�
s$
zRefactoringTool.write_filez>>> z... c
Csg}d}d}d}d}x�|jdd�D]�}|d7}|j�j|j�r�|dk	r\|j|j||||��|}|g}|j|j�}	|d|	�}q"|dk	r�|j||j�s�|||jj�dkr�|j	|�q"|dk	r�|j|j||||��d}d}|j	|�q"W|dk	�r|j|j||||��dj
|�S)a�Refactors a docstring, looking for doctests.

        This returns a modified version of the input string.  It looks
        for doctests, which start with a ">>>" prompt, and may be
        continued with "..." prompts, as long as the "..." is indented
        the same as the ">>>".

        (Unfortunately we can't use the doctest module's parser,
        since, like most parsers, it is not geared towards preserving
        the original source.)
        NrT)�keependsrr>r})�
splitlines�lstripr�PS1r2�refactor_doctest�find�PS2�rstriprr�)
rzr@r��result�blockZblock_lineno�indent�lineno�line�irrrr�%s:



z"RefactoringTool.refactor_docstringc
sy�j||��}Wndtk
rv}zH�jjtj�rRx|D]}�jd|jd��q8W�jd|||j	j
|�|Sd}~XnX�j||��r
t|�j
dd�}|d|d�||dd�}	}|djd�s�|dd7<��j|jd�g}|�r
|��fd	d
�|D�7}|S)
z�Refactors one doctest.

        A doctest is given as a block of lines, the first of which starts
        with ">>>" (possibly indented), while the remaining lines start
        with "..." (identically indented).

        z
Source: %sr>z+Can't parse docstring in %s line %s: %s: %sNT)r�rrcsg|]}��j|�qSr)r�)r7r�)r�rzrrr:jsz4RefactoringTool.refactor_doctest.<locals>.<listcomp>r�r�)�parse_blockr'reZisEnabledForro�DEBUGr�r�r�r�rr�r�r�rr��pop)
rzr�r�r�r�r�r�r�r�Zclippedr)r�rzrr�Ps$
"z RefactoringTool.refactor_doctestcCs�|jrd}nd}|js$|jd|�n&|jd|�x|jD]}|j|�q8W|jrt|jd�x|jD]}|j|�qbW|jr�t|j�dkr�|jd�n|jdt|j��x&|jD]\}}}|j|f|�|�q�WdS)	N�werez
need to bezNo files %s modified.zFiles that %s modified:z$Warnings/messages while refactoring:rzThere was 1 error:zThere were %d errors:)rqrur�rprnr�)rzr��file�messager�r�r�rrr�	summarizems$
zRefactoringTool.summarizecCs"|jj|j|||��}t�|_|S)z�Parses a block into a tree.

        This is necessary to get correct line number / offset information
        in the parser diagnostics and embedded into the parse tree.
        )rZparse_tokens�	wrap_toksrPr�)rzr�r�r�r�rrrr��szRefactoringTool.parse_blockccshtj|j||�j�}xN|D]F\}}\}}\}	}
}||d7}|	|d7}	||||f|	|
f|fVqWdS)z;Wraps a tokenize stream to systematically modify start/end.rN)rrL�	gen_lines�__next__)rzr�r�r�r1r#r]Zline0Zcol0Zline1Zcol1Z	line_textrrrr��s
zRefactoringTool.wrap_toksccs�||j}||j}|}xV|D]N}|j|�r@|t|�d�Vn(||j�dkrXdVntd||f��|}qWx
dVqrWdS)z�Generates lines as expected by tokenize from a list of lines.

        This strips the first len(indent + self.PS1) characters off each line.
        Nr>zline=%r, prefix=%rr})r�r�rr�r��AssertionError)rzr�r��prefix1Zprefix2�prefixr�rrrr��s



zRefactoringTool.gen_lines)NN)FF)FF)FF)F)NFN)N)rr r!rhr�r�r{rrr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrra�s:
4(
	


O

+
rac@seZdZdS)�MultiprocessingUnsupportedN)rr r!rrrrr��sr�csBeZdZ�fdd�Zd�fdd�	Z�fdd�Z�fd	d
�Z�ZS)�MultiprocessRefactoringToolcs"tt|�j||�d|_d|_dS)N)�superr�r{�queue�output_lock)rzr��kwargs)r�rrr{�sz$MultiprocessRefactoringTool.__init__Frcs|dkrtt��j|||�Syddl�Wntk
r@t�YnX�jdk	rTtd���j��_�j	��_
��fdd�t|�D�}z.x|D]}|j�q�Wtt��j|||�Wd�jj
�xt|�D]}�jjd�q�Wx|D]}|j�r�|j
�q�Wd�_XdS)Nrrz already doing multiple processescsg|]}�j�jd��qS))�target)ZProcess�_child)r7r�)�multiprocessingrzrrr:�sz8MultiprocessRefactoringTool.refactor.<locals>.<listcomp>)r�r�r�r��ImportErrorr�r��RuntimeErrorZ
JoinableQueueZLockr��range�startr��putZis_alive)rzr�r�r�Z
num_processesZ	processesr)r�)r�)r�rzrr��s2









z$MultiprocessRefactoringTool.refactorc
sR|jj�}xB|dk	rL|\}}ztt|�j||�Wd|jj�X|jj�}qWdS)N)r�rmr�r�r�Z	task_done)rzZtaskr�r�)r�rrr��s


z"MultiprocessRefactoringTool._childcs2|jdk	r|jj||f�ntt|�j||�SdS)N)r�r�r�r�r�)rzr�r�)r�rrr��s

z)MultiprocessRefactoringTool.refactor_file)FFr)rr r!r{r�r�r��
__classcell__rr)r�rr��s
r�)T)rr)(r`�
__author__rr�ror�r+rM�	itertoolsrZpgen2rrrZ
fixer_utilrr}rr	r
rvrr'rr$r5r;r=�version_info�codecsr�r�rArCr^r_�objectrar�r�rrrr�<module>	sF



(	

Youez - 2016 - github.com/yon3zu
LinuXploit