Plan 9 from Bell Labs’s /usr/web/sources/contrib/jas/root/sys/lib/python2.7/lib2to3/main.pyc

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


��Qc@�s�dZddlmZddlZddlZddlZddlZddlZddlZddl	m
Z
d�Zde
jfd��YZ
d	�Zdd
�ZdS(s
Main program for 2to3.
i�(twith_statementNi(trefactorc	C�s:|j�}|j�}tj||||dddd�S(s%Return a unified diff of two strings.s
(original)s(refactored)tlinetermt(t
splitlinestdifflibtunified_diff(tatbtfilename((s"/sys/lib/python2.7/lib2to3/main.pyt
diff_textss
	tStdoutRefactoringToolcB�s;eZdZdddd�Zd�Zd�Zd�ZRS(s2
    A refactoring tool that can avoid overwriting its input files.
    Prints output to stdout.

    Output files can optionally be written to a different directory and or
    have an extra file suffix appended to their name for use in situations
    where you do not want to replace the input files.
    Rc		C�sv||_||_|r;|jtj�r;|tj7}n||_||_||_tt	|�j
|||�dS(sF
        Args:
            fixers: A list of fixers to import.
            options: A dict with RefactoringTool configuration.
            explicit: A list of fixers to run even if they are explicit.
            nobackups: If true no backup '.bak' files will be created for those
                files that are being refactored.
            show_diffs: Should diffs of the refactoring be printed to stdout?
            input_base_dir: The base directory for all input files.  This class
                will strip this path prefix off of filenames before substituting
                it with output_dir.  Only meaningful if output_dir is supplied.
                All files processed by refactor() must start with this path.
            output_dir: If supplied, all converted files will be written into
                this directory tree instead of input_base_dir.
            append_suffix: If supplied, all files output by this tool will have
                this appended to their filename.  Useful for changing .py to
                .py3 for example by passing append_suffix='3'.
        N(t	nobackupst
show_diffstendswithtostsept_input_base_dirt_output_dirt_append_suffixtsuperRt__init__(	tselftfixerstoptionstexplicitRR
tinput_base_dirt
output_dirt
append_suffix((s"/sys/lib/python2.7/lib2to3/main.pyR$s					cO�s3|jj|||f�|jj|||�dS(N(terrorstappendtloggerterror(Rtmsgtargstkwargs((s"/sys/lib/python2.7/lib2to3/main.pyt	log_errorAsc
C�s�|}|jre|j|j�rItjj|j|t|j��}qetd||jf��n|jr~||j7}n||kr�tjj	|�}tjj
|�s�tj|�n|jd||�n|j
sy|d}tjj|�r6ytj|�Wq6tjk
r2}|jd|�q6Xnytj||�Wqytjk
ru}|jd||�qyXntt|�j}	|	||||�|j
s�tj||�n||kr�tj||�ndS(Ns5filename %s does not start with the input_base_dir %ssWriting converted %s to %s.s.baksCan't remove backup %ssCan't rename %s to %s(Rt
startswithRRtpathtjointlent
ValueErrorRtdirnametisdirtmakedirstlog_messageRtlexiststremoveR trenameRRt
write_filetshutiltcopymode(
Rtnew_textR	told_texttencodingt
orig_filenameRtbackupterrtwrite((s"/sys/lib/python2.7/lib2to3/main.pyR1Es@		
	
	cC�s�|r|jd|�n�|jd|�|jr�t|||�}y_|jdk	r�|j�x|D]}|GHqgWtjj�WdQXnx|D]}|GHq�WWq�tk
r�t	d|f�dSXndS(NsNo changes to %ss
Refactored %ss+couldn't encode %s's diff for your terminal(
R-R
R
toutput_locktNonetsyststdouttflushtUnicodeEncodeErrortwarn(RtoldtnewR	tequalt
diff_linestline((s"/sys/lib/python2.7/lib2to3/main.pytprint_outputls"	

	


(t__name__t
__module__t__doc__RR$R1RG(((s"/sys/lib/python2.7/lib2to3/main.pyRs
		'cC�stjd|fIJdS(NsWARNING: %s(R=tstderr(R!((s"/sys/lib/python2.7/lib2to3/main.pyRA�sc�s�tjdd�}|jdddddd�|jd	d
dddgdd
�|jdddddddddd�|jdddddgdd�|jdddddd�|jdddddd�|jdddddd �|jd!dddd"�|jd#d$dddd%�|jd&d'dddtdd(�|jd)d*dddd+dd,dd-�|jd.d/dddd0�|jd1dddd+dd,dd2�t}i}|j|�\}}|jrt|d3<|js�d4�nt|_n|j	r'|j
r'|jd5�n|jrJ|j
rJ|jd6�n|jrj|j
rjtd7�n|jr�|j
r�|jd8�n|jr�d9GHxtj��D]}|GHq�W|s�d:Sn|s�jd;IJtjd<IJd=Sd>|krt}|jrtjd?IJd=Sn|jr0t|d@<n|jrBtjntj}tjdAdBdC|�tjdD�}ttj���}	t�fdE�|jD��}
t�}|jrt}x;|jD]0}
|
dFkr�}q�|j�dG|
�q�W|r|	j|�n|}n|	j|�}|j |
�}t!j"j#|�}|r�|j$t!j%�r�t!j"j&|�r�t!j"j'|�}n|j	r�|j(t!j%�}|j)dH|j	|�nt*t+|�|t+|�|j
|j
dI|dJ|j	dK|j�}|j,s�|r|j-�n]y#|j||j|j.|j/�Wn7tj0k
rx|j/dksgt1�tjdLIJdSX|j2�nt3t4|j,��S(Ms�Main program.

    Args:
        fixer_pkg: the name of a package where the fixers are located.
        args: optional; a list of command line arguments. If omitted,
              sys.argv[1:] is used.

    Returns a suggested exit status (0, 1, 2).
    tusages2to3 [options] file|dir ...s-ds--doctests_onlytactiont
store_truethelpsFix up doctests onlys-fs--fixRtdefaults1Each FIX specifies a transformation; default: alls-js--processeststoreittypetintsRun 2to3 concurrentlys-xs--nofixs'Prevent a transformation from being runs-ls--list-fixessList available transformationss-ps--print-functions0Modify the grammar so that print() is a functions-vs	--verbosesMore verbose loggings
--no-diffss#Don't show diffs of the refactorings-ws--writesWrite back modified filess-ns--nobackupss&Don't write backups for modified filess-os--output-dirtstrRsXPut output files in this directory instead of overwriting the input files.  Requires -n.s-Ws--write-unchanged-filessYAlso write files even if no changes were required (useful with --output-dir); implies -w.s--add-suffixsuAppend this string to all output filenames. Requires -n if non-empty.  ex: --add-suffix='3' will generate .py3 files.twrite_unchanged_filess&--write-unchanged-files/-W implies -w.s%Can't use --output-dir/-o without -n.s"Can't use --add-suffix without -n.s@not writing files and not printing diffs; that's not very usefulsCan't use -n without -ws2Available transformations for the -f/--fix option:is1At least one file or directory argument required.sUse --help to show usage.it-sCan't write to stdin.tprint_functiontformats%(name)s: %(message)stlevelslib2to3.mainc3�s|]}�d|VqdS(s.fix_N((t.0tfix(t	fixer_pkg(s"/sys/lib/python2.7/lib2to3/main.pys	<genexpr>�stalls.fix_s7Output in %r will mirror the input directory %r layout.RRRs+Sorry, -j isn't supported on this platform.(5toptparsetOptionParsert
add_optiontFalset
parse_argsRUtTrueR:RARRR t
add_suffixtno_diffst
list_fixesRtget_all_fix_namesR=RKRWtverbosetloggingtDEBUGtINFOtbasicConfigt	getLoggertsettget_fixers_from_packagetnofixR[taddtuniont
differenceRR&tcommonprefixRRR+R*trstriptinfoRtsortedRtrefactor_stdint
doctests_onlyt	processestMultiprocessingUnsupportedtAssertionErrort	summarizeRStbool(R\R"tparserRxtflagsRtfixnameRYRtavail_fixestunwanted_fixesRtall_presentR[t	requestedtfixer_namesRtrt((R\s"/sys/lib/python2.7/lib2to3/main.pytmain�s�

	
	

		

	
	
							


(RJt
__future__RR=RRRiR2R^RRR
tMultiprocessRefactoringToolRRAR<R�(((s"/sys/lib/python2.7/lib2to3/main.pyt<module>s		h	

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.