HEX

Warning: set_time_limit() [function.set-time-limit]: Cannot set time limit - prohibited by configuration in /home/u547966/brikov.ru/www/wp-content/plugins/admin-menu-editor/menu-editor.php on line 745
Server: Apache
System: Linux 4.19.0-0.bpo.9-amd64 x86_64 at red40
User: u547966 (5490)
PHP: 5.3.29-mh2
Disabled: syslog, dl, popen, proc_open, proc_nice, proc_get_status, proc_close, proc_terminate, posix_mkfifo, chown, chgrp, accelerator_reset, opcache_reset, accelerator_get_status, opcache_get_status, pcntl_alarm, pcntl_fork, pcntl_waitpid, pcntl_wait, pcntl_wifexited, pcntl_wifstopped, pcntl_wifsignaled, pcntl_wifcontinued, pcntl_wexitstatus, pcntl_wtermsig, pcntl_wstopsig, pcntl_signal, pcntl_signal_dispatch, pcntl_get_last_error, pcntl_strerror, pcntl_sigprocmask, pcntl_sigwaitinfo, pcntl_sigtimedwait, pcntl_exec, pcntl_getpriority, pcntl_setpriority
Upload Files
File: //usr/lib/python3.7/lib2to3/__pycache__/refactor.cpython-37.pyc
B

µ5»a0kã@sdZdZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mZmZm
Z
ddlmZddlmZmZdd	lmZd!dd„ZGd
d„deƒZdd„Zdd„Zdd„Zdd„Zdd„ZGdd„deƒZGdd„deƒZGdd„deƒZ Gdd „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 <guido@python.org>éN)Úchainé)ÚdriverÚtokenizeÚtoken)Ú	find_root)ÚpytreeÚpygram)Úbtm_matcherTcCstt|ggdgƒ}tj |j¡}g}xLtt |¡ƒD]:}| d¡r2| d¡r2|rZ|dd…}| 	|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/lib/python3.7/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]}| t|ƒ¡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Êt t¡}g}x„|D]|}|jrjyt|jƒ}Wntk
rJ| |¡YqXxB|D]}|| |¡qRWq|jdk	r†||j |¡q| |¡qWx,tt	j
j ¡t	j
j
ƒD]}|| |¡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"



r4cs‡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)r8r)r8rÚget_fixers_from_packageds
r:cCs|S)Nr)ÚobjrrrÚ	_identityksr<csVd}t t |¡j¡‰‡fdd„}ttjtjtj	hƒ}t
ƒ}yúxô|ƒ\}}||krVq@q@|tjkrl|rfPd}q@|tjkr.|dkr.|ƒ\}}|tjksž|dkr P|ƒ\}}|tjks¼|dkr¾P|ƒ\}}|tj
krä|dkrä|ƒ\}}xJ|tjkr*| |¡|ƒ\}}|tj
ks|d	krP|ƒ\}}qæWq@Pq@WWntk
rLYnXt|ƒS)
NFcstˆƒ}|d|dfS)Nrr)Únext)Útok)ÚgenrrÚadvancersz(_detect_future_features.<locals>.advanceTÚfromZ
__future__Úimportú(ú,)rÚgenerate_tokensÚioÚStringIOÚreadlineÚ	frozensetrÚNEWLINEÚNLÚCOMMENTr$ÚSTRINGÚNAMEÚOPÚaddÚ
StopIteration)ÚsourceZhave_docstringr@ÚignoreÚfeaturesÚtpÚvaluer)r?rÚ_detect_future_featuresosD








rWc@seZdZdZdS)Ú
FixerErrorzA fixer could not be loaded.N)rrr Ú__doc__rrrrrX—srXc@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|_|j ¡|_|dk	r0|j |¡|jdrDtj|_ntj	|_|j 
d¡|_g|_t
 d¡|_g|_d|_tj|jtj|jd|_| ¡\|_|_g|_t ¡|_g|_g|_xXt|j|jƒD]F}|j rä|j !|¡qÌ||jkrü|j "|¡qÌ||jkrÌ|j "|¡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.
        Nr[r\rZF)ÚconvertÚlogger)&ÚfixersÚexplicitÚ_default_optionsÚcopyÚoptionsr%r	Ú!python_grammar_no_print_statementÚgrammarr.Úgetr\ÚerrorsÚloggingZ	getLoggerr^Ú	fixer_logÚwroterZDriverrr]Ú
get_fixersÚ	pre_orderÚ
post_orderÚfilesÚbmZ
BottomMatcherÚBMZ
bmi_pre_orderZbmi_post_orderrZ
BM_compatibleZ	add_fixerrr4Úbmi_pre_order_headsÚbmi_post_order_heads)ÚselfZfixer_namesrcr`r3rrrÚ__init__£s<





zRefactoringTool.__init__c	Cs^g}g}x(|jD]}t|iidgƒ}| dd¡d}| |j¡rV|t|jƒd…}| d¡}|jd dd	„|Dƒ¡}yt	||ƒ}Wn&t
k
r®td
||fƒd‚YnX||j|j
ƒ}	|	jræ|jdk	ræ||jkræ| d|¡q| d
|¡|	jdkr
| |	¡q|	jdkr"| |	¡qtd|	jƒ‚qWt d¡}
|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.
        rr5réÿÿÿÿNÚ_ÚcSsg|]}| ¡‘qSr)Útitle)r6r(rrrr9çsz.RefactoringTool.get_fixers.<locals>.<listcomp>zCan't find %s.%sTzSkipping optional fixer: %szAdding transformation: %sZpreZpostzIllegal fixer order: %rZ	run_order)Úkey)r_rÚrsplitrÚFILE_PREFIXÚlenÚsplitÚCLASS_PREFIXÚjoinÚgetattrÚAttributeErrorrXrcrir`Úlog_messageÚ	log_debugÚorderrÚoperatorÚ
attrgetterÚsort)rsZpre_order_fixersZpost_order_fixersZfix_mod_pathÚmodr7ÚpartsÚ
class_nameZ	fix_classr3Zkey_funcrrrrk×s8


zRefactoringTool.get_fixerscOs‚dS)zCalled when an error occurs.Nr)rsÚmsgÚargsÚkwdsrrrÚ	log_errorÿszRefactoringTool.log_errorcGs|r||}|j |¡dS)zHook to log a message.N)r^Úinfo)rsr‹rŒrrrr‚szRefactoringTool.log_messagecGs|r||}|j |¡dS)N)r^Údebug)rsr‹rŒrrrrƒ	szRefactoringTool.log_debugcCsdS)zTCalled with the old version, new version, and filename of a
        refactored file.Nr)rsÚold_textÚnew_textÚfilenameÚequalrrrÚprint_outputszRefactoringTool.print_outputcCs<x6|D].}tj |¡r&| |||¡q| |||¡qWdS)z)Refactor a list of files and directories.N)rrÚisdirÚrefactor_dirÚ
refactor_file)rsÚitemsÚwriteÚ
doctests_onlyZdir_or_filerrrÚrefactors
zRefactoringTool.refactorc
Cs¢tjd}x’t |¡D]„\}}}| d|¡| ¡| ¡xF|D]>}| d¡sBtj |¡d|krBtj ||¡}	| 	|	||¡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 %sr5rcSsg|]}| d¡s|‘qS)r5)r)r6Zdnrrrr9.sz0RefactoringTool.refactor_dir.<locals>.<listcomp>N)
rÚextsepÚwalkrƒr‡rrÚsplitextrr˜)
rsZdir_nameršr›Zpy_extÚdirpathZdirnamesÚ	filenamesrÚfullnamerrrr—s


zRefactoringTool.refactor_dirc
CsŠyt|dƒ}Wn0tk
r>}z| d||¡dSd}~XYnXzt |j¡d}Wd| ¡Xtj|d|dd}| ¡|fSQRXdS)	zG
        Do our best to decode a Python source file correctly.
        ÚrbzCan't open %s: %s)NNNrr'rw)ÚencodingÚnewline)	ÚopenÚOSErrorrŽrÚdetect_encodingrHÚcloserFÚread)rsr“ÚfÚerrr¥rrrÚ_read_python_source0s
z#RefactoringTool._read_python_sourcecCsº| |¡\}}|dkrdS|d7}|rn| d|¡| ||¡}|jsL||kr`| |||||¡q¶| d|¡nH| ||¡}|jsŠ|rª|jrª|jt|ƒdd…|||dn| d|¡dS)zRefactors a file.NÚ
zRefactoring doctests in %szNo doctest changes in %sru)ršr¥zNo changes in %s)r®rƒÚrefactor_docstringr\Úprocessed_fileÚrefactor_stringÚwas_changedÚstr)rsr“ršr›Úinputr¥ÚoutputÚtreerrrr˜@szRefactoringTool.refactor_filec
Cs–t|ƒ}d|krtj|j_zLy|j |¡}Wn6tk
rb}z| d||jj	|¡dSd}~XYnXWd|j|j_X||_
| d|¡| ||¡|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.
        r[zCan't parse %s: %s: %sNzRefactoring %s)
rWr	rdrreZparse_stringr&rŽÚ	__class__rÚfuture_featuresrƒÚ
refactor_tree)rsÚdatarrTr·r­rrrr²Ws
zRefactoringTool.refactor_stringcCsŒtj ¡}|rN| d¡| |d¡}|js2||krB| |d|¡qˆ| d¡n:| |d¡}|jsj|r~|jr~| t	|ƒd|¡n
| d¡dS)NzRefactoring doctests in stdinz<stdin>zNo doctest changes in stdinzNo changes in stdin)
ÚsysÚstdinr«rƒr°r\r±r²r³r´)rsr›rµr¶r·rrrÚrefactor_stdinrs

zRefactoringTool.refactor_stdinc

Csüx"t|j|jƒD]}| ||¡qW| |j| ¡¡| |j| ¡¡|j | 	¡¡}xtt
| ¡ƒrÎx^|jjD]P}||krv||rv||j
tjjdd|jr¼||j
tjjdxt||ƒD]ø}|||krê|| |¡yt|ƒWntk
rwÌYnX|jr&||jkr&qÌ| |¡}|rÌ| ||¡}|dk	rÌ| |¡x,| ¡D] }|jsng|_|j |¡q\W|j | 	¡¡}x2|D]*}	|	|kr¬g||	<||	 ||	¡q–WqÌWqvWq\Wx$t|j|jƒD]}| ||¡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)ryÚreverse)ryN)rrlrmZ
start_treeÚtraverse_byrqrrrpÚrunZleavesÚanyr/r_r‡rZBaseZdepthZkeep_line_orderZ
get_linenor,ÚremoverÚ
ValueErrorZfixers_appliedÚmatchÚ	transformÚreplacerr1Zfinish_treer³)
rsr·rr3Z	match_setÚnodeÚresultsÚnewZnew_matchesZfxrrrrrº‚sJ



$zRefactoringTool.refactor_treecCs^|sdSxP|D]H}xB||jD]4}| |¡}|r| ||¡}|dk	r| |¡|}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Ç)rsr_Z	traversalrÈr3rÉrÊrrrrÀÑs


zRefactoringTool.traverse_bycCs†|j |¡|dkr.| |¡d}|dkr.dS||k}| ||||¡|r`| d|¡|js`dS|rv| ||||¡n| d|¡dS)zR
        Called when a file has been refactored and there may be changes.
        NrzNo changes to %szNot writing changes to %s)rnrr®r•rƒr\Ú
write_file)rsr’r“r‘ršr¥r”rrrr±èszRefactoringTool.processed_filecCs®ytj|d|dd}Wn0tk
rF}z| d||¡dSd}~XYnX|Fy| |¡Wn0tk
rŒ}z| d||¡Wdd}~XYnXWdQRX| d|¡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.
        Úwrw)r¥r¦zCan't create %s: %sNzCan't write %s: %szWrote changes to %sT)rFr§r¨rŽršrƒrj)rsr’r“r‘r¥Úfpr­rrrrËýs*zRefactoringTool.write_filez>>> z... c
	Csg}d}d}d}d}xØ|jddD]È}|d7}| ¡ |j¡r€|dk	r\| | ||||¡¡|}|g}| |j¡}	|d|	…}q"|dk	rº| ||j¡s®|||j ¡dkrº| 	|¡q"|dk	rØ| | ||||¡¡d}d}| 	|¡q"W|dk	r| | ||||¡¡d 
|¡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¯rw)Ú
splitlinesÚlstriprÚPS1r1Úrefactor_doctestÚfindÚPS2Úrstriprr)
rsrµr“ÚresultÚblockZblock_linenoÚindentÚlinenoÚlineÚirrrr°s:



z"RefactoringTool.refactor_docstringc

s*yˆ ||ˆ¡}Wnftk
rx}zHˆj tj¡rRx|D]}ˆ d| d¡¡q8Wˆ d|||j	j
|¡|Sd}~XYnXˆ ||¡r&t|ƒj
dd}|d|d…||dd…}	}|	dg|dksÔt|	ƒ‚|d d¡sò|dd7<ˆˆj| d	¡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Îrrurcsg|]}ˆˆj|‘qSr)rÔ)r6rÚ)rØrsrrr9Zsz4RefactoringTool.refactor_doctest.<locals>.<listcomp>)Úparse_blockr&r^ZisEnabledForrhÚDEBUGrƒrÕrŽr¸rrºr´rÏÚAssertionErrorrrÑÚpop)
rsr×rÙrØr“r·r­rÚrÊZclippedr)rØrsrrÒ@s&
"z RefactoringTool.refactor_doctestcCsÒ|jrd}nd}|js$| d|¡n&| d|¡x|jD]}| |¡q8W|jrt| d¡x|jD]}| |¡qbW|jrÎt|jƒdkr”| d¡n| dt|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:)rjrnr‚rirgr|)rsràÚfileÚmessager‹rŒrrrrÚ	summarize]s$
zRefactoringTool.summarizecCs"|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_toksrIr¹)rsr×rÙrØr·rrrrÜtszRefactoringTool.parse_blockccsht | ||¡j¡}xN|D]F\}}\}}\}	}
}||d7}|	|d7}	||||f|	|
f|fVqWdS)z;Wraps a tokenize stream to systematically modify start/end.rN)rrEÚ	gen_linesÚ__next__)rsr×rÙrØr0r"rVZline0Zcol0Zline1Zcol1Z	line_textrrrrä~s
zRefactoringTool.wrap_toksccs€||j}||j}|}xV|D]N}| |¡r@|t|ƒd…Vn(|| ¡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=%rrw)rÑrÔrr|rÕrÞ)rsr×rØÚprefix1Zprefix2ÚprefixrÚrrrråŒs



zRefactoringTool.gen_lines)NN)FF)FF)FF)F)NFN)N)rrr rar~r{rtrkrŽr‚rƒr•rœr—r®r˜r²r¾rºrÀr±rËrÑrÔr°rÒrãrÜrärårrrrrZ›s:
4(
	


O

+
rZc@seZdZdS)ÚMultiprocessingUnsupportedN)rrr rrrrré srécsBeZdZ‡fdd„Zd‡fdd„	Z‡fdd„Z‡fd	d
„Z‡ZS)ÚMultiprocessRefactoringToolcs"tt|ƒj||Žd|_d|_dS)N)ÚsuperrêrtÚqueueÚoutput_lock)rsrŒÚkwargs)r¸rrrt¦sz$MultiprocessRefactoringTool.__init__Frc
s|dkrttˆƒ |||¡Syddl‰Wntk
r@t‚YnXˆjdk	rTtdƒ‚ˆ ¡ˆ_ˆ 	¡ˆ_
‡‡fdd„t|ƒDƒ}z.x|D]}| ¡qˆWttˆƒ |||¡Wdˆj 
¡xt|ƒD]}ˆj d¡qÄWx|D]}| ¡rÞ| 
¡qÞWdˆ_XdS)Nrrz already doing multiple processescsg|]}ˆjˆjd‘qS))Útarget)ZProcessÚ_child)r6rÛ)Úmultiprocessingrsrrr9¸sz8MultiprocessRefactoringTool.refactor.<locals>.<listcomp>)rërêrœrñÚImportErrorrérìÚRuntimeErrorZ
JoinableQueueZLockríÚrangeÚstartrÚputZis_alive)rsr™ršr›Z
num_processesZ	processesr(rÛ)r¸)rñrsrrœ«s2









z$MultiprocessRefactoringTool.refactorcsR|j ¡}xB|dk	rL|\}}ztt|ƒj||ŽWd|j ¡X|j ¡}qWdS)N)rìrfrërêr˜Z	task_done)rsZtaskrŒrî)r¸rrrðÈs


z"MultiprocessRefactoringTool._childcs2|jdk	r|j ||f¡ntt|ƒj||ŽSdS)N)rìrörërêr˜)rsrŒrî)r¸rrr˜Ós

z)MultiprocessRefactoringTool.refactor_file)FFr)rrr rtrœrðr˜Ú
__classcell__rr)r¸rrê¤s
rê)T)"rYÚ
__author__rFrr¼rhr…r*Ú	itertoolsrZpgen2rrrZ
fixer_utilrrwrr	r
rorr&rr#r4r:r<rWrXÚobjectrZrérêrrrrÚ<module>	s6

(