Ë ZjáNÛ¤+ãó’—dZddlmZmZddlZddlZddlZddlZddlZddl Z ddl m Z d„Z Gd„de j«Zd „Zd d „Zy) z Main program for 2to3. é)Úwith_statementÚprint_functionNé)Úrefactorc óz—|j«}|j«}tj||||ddd¬«S)z%Return a unified diff of two strings.z (original)z (refactored)Ú)Úlineterm)Ú splitlinesÚdifflibÚ unified_diff)ÚaÚbÚfilenames ú#/usr/lib/python3.12/lib2to3/main.pyÚ diff_textsrs;€à � ‰ ‹€AØ � ‰ ‹€AÜ × Ñ   1 h°Ø ,¨nØ)+ô -ð-ócó<‡—eZdZdZ dˆfd„ Zd„Zˆfd„Zd„ZˆxZS)ÚStdoutRefactoringToola2 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. c óÞ•—||_||_|r2|jtj«s|tjz }||_||_||_tt|�+|||«y)aF 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) Ú nobackupsÚ show_diffsÚendswithÚosÚsepÚ_input_base_dirÚ _output_dirÚ_append_suffixÚsuperrÚ__init__) ÚselfÚfixersÚoptionsÚexplicitrrÚinput_base_dirÚ output_dirÚ append_suffixÚ __class__s €rrzStdoutRefactoringTool.__init__$saø€ð(#ˆŒØ$ˆŒÙ  .×"9Ñ"9¼"¿&¹&Ô"AØ œbŸf™fÑ $ˆNØ-ˆÔØ%ˆÔØ+ˆÔÜ Ô# TÑ3°F¸GÀXÕNrcó€—|jj|||f«|jj|g|¢­i|¤Žy©N)ÚerrorsÚappendÚloggerÚerror)r ÚmsgÚargsÚkwargss rÚ log_errorzStdoutRefactoringTool.log_errorAs9€Ø � ‰ ×јC  vÐ.Ô/؈� ‰ ×ј#Ð/ Ò/¨Ó/rcó•—|}|jrw|j|j«rAtjj |j|t |j«d«}ntd|›d|j›�«‚|jr||jz }||k7rhtjj|«}tjj|«s|rtj|«|jd||«|jsQ|dz}tjj|«r tj|« tj"||«t$t&|�R}|||||«|jst+j,|«||k7rt+j,||«yy#t $r|jd|«YŒŒwxYw#t $r|jd||«YŒ—wxYw)Nz filename z( does not start with the input_base_dir zWriting converted %s to %s.z.bakzCan't remove backup %szCan't rename %s to %s)rÚ startswithrrÚpathÚjoinÚlenÚ ValueErrorrÚdirnameÚisdirÚmakedirsÚ log_messagerÚlexistsÚremoveÚOSErrorÚrenamerrÚ write_fileÚshutilÚcopymode) r Únew_textrÚold_textÚencodingÚ orig_filenamer%ÚbackupÚwriter's €rr@z StdoutRefactoringTool.write_fileEs¾ø€Ø ˆ Ø × Ò Ø×"Ñ" 4×#7Ñ#7Ô8ÜŸ7™7Ÿ<™<¨×(8Ñ(8Ø(0´°T×5IÑ5IÓ1JÐ1KÐ(LóN‘õ!â)1°4×3GÒ3Gð"IóJðJð × Ò Ø ˜×+Ñ+Ñ +ˆHØ ˜HÒ $ÜŸ™Ÿ™¨Ó2ˆJÜ—7‘7—=‘= Ô,±Ü— ‘ ˜JÔ'Ø × Ñ Ð:¸MØ%ô 'à�~Š~à Ñ&ˆFÜ�w‰w�‰˜vÔ&ðGÜ—I‘I˜fÔ%ð LÜ— ‘ ˜( FÔ+ôÔ+¨TÑ=ˆÙ ˆh˜ (¨HÔ5Ø�~Š~Ü �O‰O˜F HÔ -Ø ˜HÒ $ä �O‰O˜M¨8Õ 4ð %øôòGØ×$Ñ$Ð%=¸vÖFðGûôò LØ× Ñ Ð!8¸(ÀFÖKð Lús$ÅGÅG%ÇG"Ç!G"Ç%HÈHcó¤—|r|jd|«y|jd|«|jrst|||«} |j�F|j5|D] }t |«Œt j j«ddd«y|D] }t |«Œyy#1swYyxYw#t$rtd|›d�«YywxYw)NzNo changes to %sz Refactored %szcouldn't encode z's diff for your terminal) r;rrÚ output_lockÚprintÚsysÚstdoutÚflushÚUnicodeEncodeErrorÚwarn)r ÚoldÚnewrÚequalÚ diff_linesÚlines rÚ print_outputz"StdoutRefactoringTool.print_outputls€٠Ø × Ñ Ð/°Õ :à × Ñ ˜_¨hÔ 7Ø�ŠÜ'¨¨S°(Ó;� ð Ø×'Ñ'Ð3Ø!×-Ó-Û(2 Ü % d¥ ð)3äŸJ™J×,Ñ,Ô.÷.Ð-ó %/˜DÜ! $�Kñ%/ð÷.Ð-ûô*òÝÚ"ð%ô&áðús6ÁB4Á1B( B4ÂB4Â(B1Â-B4Â1B4Â4CÃC)rrr) Ú__name__Ú __module__Ú __qualname__Ú__doc__rr1r@rVÚ __classcell__)r's@rrrs%ø„ñðBDõOò:0ô%5öNrrcó@—td|›�tj¬«y)Nz WARNING: ©Úfile)rKrLÚstderr)r.s rrPrP�s€Ý ™3Ð ¤s§z¡zÖ2rc ó¾ ‡—tjd¬«}|jdddd¬«|jdd d gd ¬ «|jd ddddd¬«|jddd gd¬ «|jdddd¬«|jdddd¬«|jdddd¬«|jd d!dd"¬«|jd#dd$¬«|jd%d&dd'¬«|jd(d)dd*d+¬ «|jd,d-dd.d/d0¬1«|jd2d3dd4¬«|jd5dd.d/d6¬1«d*}i}|j|«\}}|jr#d7|d8<|j s t d9«d7|_|jr|js|jd:«|jr|js|jd;«|j s|jr t d<«|j s|jr|jd=«|jr3td>«tj‰«D] }t|«Œ|sy?|s7td@t j"¬A«tdBt j"¬A«yCdD|vr*d7}|j rtdEt j"¬A«yC|j$rd7|dF<|j&rd7|dG<|j(rt*j,nt*j.}t+j0dH|¬I«t+j2dJ«}t5tj6‰««} t5ˆfdK„|j8D««} t5«} |j:rHd*} |j:D]!} | dLk(rd7} Œ | j=‰dMz| z«Œ#| r| j?| «n| }n| j?| «}|jA| «}tBjDjG|«}|r]|jItBjJ«s>tBjDjM|«stBjDjO|«}|jr<|jQtBjJ«}|jSdN|j|«tUtW|«|tW| «|j|j ||j|j¬O«}|jXsV|r|j[«n3 |j||j |j\|j^«|jc«tetg|jX««S#tj`$r/|j^dkDsJ‚tdPt j"¬A«YywxYw)Qzþ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). z2to3 [options] file|dir ...)Úusagez-dz--doctests_onlyÚ store_truezFix up doctests only)ÚactionÚhelpz-fz--fixr+z1Each FIX specifies a transformation; default: all)rcÚdefaultrdz-jz --processesÚstorerÚintzRun 2to3 concurrently)rcreÚtyperdz-xz--nofixz'Prevent a transformation from being runz-lz --list-fixeszList available transformationsz-pz--print-functionz0Modify the grammar so that print() is a functionz-ez--exec-functionz/Modify the grammar so that exec() is a functionz-vz --verbosezMore verbose loggingz --no-diffsz#Don't show diffs of the refactoringz-wz--writezWrite back modified filesz-nz --nobackupsFz&Don't write backups for modified filesz-oz --output-dirÚstrrzXPut output files in this directory instead of overwriting the input files. Requires -n.)rcrhrerdz-Wz--write-unchanged-fileszYAlso write files even if no changes were required (useful with --output-dir); implies -w.z --add-suffixzuAppend this string to all output filenames. Requires -n if non-empty. ex: --add-suffix='3' will generate .py3 files.TÚwrite_unchanged_filesz&--write-unchanged-files/-W implies -w.z%Can't use --output-dir/-o without -n.z"Can't use --add-suffix without -n.z@not writing files and not printing diffs; that's not very usefulzCan't use -n without -wz2Available transformations for the -f/--fix option:rz1At least one file or directory argument required.r]zUse --help to show usage.éÚ-zCan't write to stdin.rÚ exec_functionz%(name)s: %(message)s)ÚformatÚlevelz lib2to3.mainc3ó.•K—|] }‰dz|z–—Œy­w)ú.fix_N©)Ú.0ÚfixÚ fixer_pkgs €rÚ zmain..âsøèø€ÐL¹m°s˜ WÑ,¨sÕ2¹mùsƒÚallrqz7Output in %r will mirror the input directory %r layout.)r$r%r&z+Sorry, -j isn't supported on this platform.)4ÚoptparseÚ OptionParserÚ add_optionÚ parse_argsrjrHrPr%rr-Ú add_suffixÚno_diffsÚ list_fixesrKrÚget_all_fix_namesrLr_rrmÚverboseÚloggingÚDEBUGÚINFOÚ basicConfigÚ getLoggerÚsetÚget_fixers_from_packageÚnofixrtÚaddÚunionÚ differencerr4Ú commonprefixrrr9r8ÚrstripÚinforÚsortedr*Úrefactor_stdinÚ doctests_onlyÚ processesÚMultiprocessingUnsupportedÚ summarizergÚbool)rur/Úparserr�Úflagsr"Úfixnameror,Ú avail_fixesÚunwanted_fixesr#Ú all_presentrtÚ requestedÚ fixer_namesr$Úrts` rÚmainrŸ…soø€ô× "Ñ "Ð)FÔ G€FØ ×Ñ�dÐ-°lØ1ðô3à ×Ñ�d˜G¨H¸bØNðôPà ×Ñ�d˜M°'À1Ø Ð'>ðô@à ×Ñ�d˜I¨hÀØDðôFà ×Ñ�d˜N°<Ø;ðô=à ×Ñ�dÐ.°|ØMðôOà ×Ñ�dÐ-°lØLðôNà ×Ñ�d˜K° Ø1ðô3à ×Ñ�l¨<Ø@ðôBà ×Ñ�d˜I¨lØ6ðô8à ×Ñ�d˜M°,ÈØCðôEà ×Ñ�d˜N°7ÀØ ð(NðôOð ×Ñ�dÐ5¸lðAðôBð ×Ñ�n¨W¸5È"ðGðôHð €NØ €EØ×%Ñ% dÓ+�M€GˆTØ×$Ò$Ø)-ˆÐ%Ñ&Ø�}Š}Ü Ð9Ô :؈Œ ð×Ò '×"3Ò"3Ø� ‰ Ð<Ô=Ø×Ò '×"3Ò"3Ø� ‰ Ð9Ô:à �=Š=˜W×-Ò-Ü Ð OÔPØ �=Š=˜W×.Ò.Ø� ‰ Ð.Ô/Ø×ÒÜ ÐBÔCÜ×1Ñ1°)Ö<ˆGÜ �'�Nð=áØÙ Ü ÐAÌÏ É ÕSÜ Ð)´· ± Õ;ØØ ˆd�{ØˆØ �=Š=Ü Ð)´· ± Õ ;ØØ×ÒØ"&ˆÐÑà×ÒØ!%ˆˆoÑð%Ÿ_š_ŒG�MŠM´'·,±,€EÜ ×ÑÐ6¸eÕDÜ × Ñ ˜~Ó .€Fô”h×6Ñ6°yÓAÓB€KÜÓL¸g¿mºmÓLÓL€NÜ‹u€H؇{‚{؈ Ø—;”;ˆCØ�eŠ|Ø"‘ à— ‘ ˜Y¨Ñ0°3Ñ6Õ7ð ñ 4?�K×%Ñ% hÔ/ÀH‰ à×%Ñ% hÓ/ˆ Ø×&Ñ& ~Ó6€KÜ—W‘W×)Ñ)¨$Ó/€NÙ˜~×6Ñ6´r·v±vÔ>Ü—‘— ‘ ˜nÔ-ôŸ™Ÿ™¨Ó8ˆØ×ÒØ'×.Ñ.¬r¯v©vÓ6ˆØ� ‰ ÐMØ×&Ñ&¨ô 8ä Ü �;Ó  ¬¨xÓ(8Ø × Ñ  7×#3Ñ#3Ð3Ø)Ø×)Ñ)Ø!×,Ñ,ô  .€Bð �9Š9Ù Ø × Ñ Õ ð Ø— ‘ ˜D '§-¡-°×1FÑ1FØ#×-Ñ-ô/ð � ‰ Œô Œt�B—I‘I‹Ó Ðøô×6Ñ6ò Ø×(Ñ(¨1Ò,Ð,Ð,ÜÐCÜŸ:™:õ'áð  úsÔ:2VÖ?W×Wr))rZÚ __future__rrrLrr r�rArxrrrÚMultiprocessRefactoringToolrrPrŸrrrrÚr¢sIðñ÷6ã Û ÛÛÛ Ûåò-ôe˜H×@Ñ@ôeòN3ôL r