⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.30
Server IP:
45.79.8.107
Server:
Linux localhost 5.15.0-140-generic #150-Ubuntu SMP Sat Apr 12 06:00:09 UTC 2025 x86_64
Server Software:
nginx/1.18.0
PHP Version:
8.1.2-1ubuntu2.21
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
lib
/
python3.10
/
lib2to3
/
__pycache__
/
View File Name :
refactor.cpython-310.pyc
o Šbcsk ã @ s d Z dZddlZddlZddlZddlZddlZddlZddlZddl m Z ddlmZm Z mZ ddlmZ ddlmZmZ dd lmZ d!dd„ZG d d„ deƒZdd„ Zdd„ Zdd„ Zdd„ Zdd„ ZG dd„ deƒZG dd„ deƒZ G dd„ deƒZ!G dd „ 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
é N)Úchainé )ÚdriverÚtokenizeÚtoken)Ú find_root)ÚpytreeÚpygram)Úbtm_matcherTc C sT t | g g dgƒ}g }t |j¡D ]\}}}| d¡r'|r"|dd… }| |¡ q|S )zEReturn a sorted list of all available fix names in the given package.Ú*Úfix_é N)Ú __import__ÚpkgutilÚiter_modulesÚ__path__Ú startswithÚappend)Ú fixer_pkgÚ remove_prefixÚpkgÚ fix_namesÚfinderÚnameÚispkg© r ú'/usr/lib/python3.10/lib2to3/refactor.pyÚget_all_fix_names s €r c @ ó e Zd ZdS )Ú _EveryNodeN©Ú__name__Ú __module__Ú__qualname__r r r r r + ó r c C sŽ t | tjtjfƒr| jdu rt‚| jhS t | tjƒr$| jr"t| jƒS t‚t | tj ƒrAt ƒ }| jD ]}|D ] }| t|ƒ¡ q4q0|S td| ƒ‚)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) Ú isinstancer ÚNodePatternÚLeafPatternÚtyper ÚNegatedPatternÚcontentÚ_get_head_typesÚWildcardPatternÚsetÚupdateÚ Exception)ÚpatÚrÚpÚxr r r r+ / s ÿr+ c C s¼ t t¡}g }| D ];}|jr1zt|jƒ}W n ty# | |¡ Y q w |D ] }|| |¡ q&q |jdur?||j |¡ q | |¡ q tt j j ¡ t j j ƒD ] }|| |¡ qPt|ƒS )z^ Accepts a list of fixers and returns a dictionary of head node type --> fixer list. N)ÚcollectionsÚdefaultdictÚlistÚpatternr+ r r Ú_accept_typer r Úpython_grammarÚ symbol2numberÚvaluesÚtokensÚextendÚdict)Ú fixer_listÚ head_nodesÚeveryÚfixerÚheadsÚ node_typer r r Ú_get_headnode_dictK s( ÿÿ ÿrE c s ‡ fdd„t ˆ dƒD ƒS )zN Return the fully qualified names for fixers in the package pkg_name. c s g | ]}ˆ d | ‘qS ©Ú.r )Ú.0Úfix_name©Úpkg_namer r Ú
h s ÿz+get_fixers_from_package.
.
F)r rJ r rJ r Úget_fixers_from_packaged s ÿrM c C s | S ©Nr )Úobjr r r Ú _identityk s rP c sj d}t t | ¡j¡‰ ‡ fdd„}ttjt jtj hƒ}t ƒ }zŠ |ƒ \}}||v r*q|tjkr5|r2ncd}n_|tjkr“|dkr“|ƒ \}}|tjksL|dkrMnR|ƒ \}}|tjks[|dkr\nH|ƒ \}}|tj kro|dkro|ƒ \}}|tjkr’| |¡ |ƒ \}}|tj ks‡|d krˆn |ƒ \}}|tjkstnnq W t|ƒS W t|ƒS W t|ƒS W t|ƒS ty´ Y t|ƒS w ) NFc s t ˆ ƒ} | d | d fS )Nr r )Únext)Útok©Úgenr r Úadvancer s z(_detect_future_features.
.advanceTÚfromÚ __future__Úimportú(ú,)r Úgenerate_tokensÚioÚStringIOÚreadlineÚ frozensetr ÚNEWLINEÚNLÚCOMMENTr- ÚSTRINGÚNAMEÚOPÚaddÚ StopIteration)ÚsourceÚhave_docstringrU ÚignoreÚfeaturesÚtpÚvaluer rS r Ú_detect_future_featureso s\ û€çýïòþþrn c @ s e Zd ZdZdS )Ú FixerErrorzA fixer could not be loaded.N)r! r" r# Ú__doc__r r r r ro — s ro c @ sê e Zd ZddddœZdZdZd4dd„Zdd „ Zd d„ Zdd „ Z dd„ Z dd„ Zd5dd„Zd5dd„Z dd„ Zd5dd„Zdd„ Zd6dd„Zdd„ Zd d!„ Z d7d"d#„Zd8d$d%„Zd&Zd'Zd(d)„ Zd*d+„ Zd,d-„ Zd.d/„ Zd0d1„ Zd2d3„ ZdS )9ÚRefactoringToolF)Úprint_functionÚ exec_functionÚwrite_unchanged_filesÚFixr Nc C sH || _ |pg | _| j ¡ | _|dur| j |¡ tj ¡ | _| jd r)| jj d= n | jd r3| jj d= | j d¡| _g | _t d¡| _g | _d| _tj| jtj| jd | _| ¡ \| _| _g | _t ¡ | _g | _g | _t| j| jƒD ]#}|j r~| j !|¡ qr|| jv rŠ| j "|¡ qr|| jv r•| j "|¡ qrt#| 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. Nrr Úprintrs Úexecrt rq F)ÚconvertÚlogger)&ÚfixersÚexplicitÚ_default_optionsÚcopyÚoptionsr. r r9 ÚgrammarÚkeywordsÚgetrt ÚerrorsÚloggingÚ getLoggerry Ú fixer_logÚwroter ÚDriverr rx Ú get_fixersÚ pre_orderÚ post_orderÚfilesÚbmÚ BottomMatcherÚBMÚ bmi_pre_orderÚbmi_post_orderr Ú BM_compatibleÚ add_fixerr rE Úbmi_pre_order_headsÚbmi_post_order_heads)ÚselfÚfixer_namesr~ r{ rB r r r Ú__init__¤ sD þ €zRefactoringTool.__init__c C sJ g }g }| j D ]ˆ}t|i i dgƒ}| dd¡d }| | j¡r(|t| jƒd… }| d¡}| jd dd „ |D ƒ¡ }zt ||ƒ}W n t yQ td ||f ƒd‚w || j| j ƒ} | jrm| jdurm|| jvrm| d|¡ q| d |¡ | jdkr~| | ¡ q| jdkr‰| | ¡ qtd| j ƒ‚t d¡} |j| d |j| d ||fS )a Inspects 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. r rG r éÿÿÿÿNÚ_Ú c S s g | ]}| ¡ ‘qS r )Útitle)rH r2 r r r rL ë s z.RefactoringTool.get_fixers.
.
zCan't find %s.%sTzSkipping optional fixer: %szAdding transformation: %sÚpreÚpostzIllegal fixer order: %rÚ run_order©Úkey)rz r Úrsplitr ÚFILE_PREFIXÚlenÚsplitÚCLASS_PREFIXÚjoinÚgetattrÚAttributeErrorro r~ r… r{ Úlog_messageÚ log_debugÚorderr ÚoperatorÚ attrgetterÚsort)r• Úpre_order_fixersÚpost_order_fixersÚfix_mod_pathÚmodrI ÚpartsÚ class_nameÚ fix_classrB Úkey_funcr r r rˆ Û s: ÿ zRefactoringTool.get_fixersc O s ‚ )zCalled when an error occurs.r )r• ÚmsgÚargsÚkwdsr r r Ú log_error s zRefactoringTool.log_errorc G s |r|| }| j |¡ dS )zHook to log a message.N)ry Úinfo©r• r· r¸ r r r r© s zRefactoringTool.log_messagec G s |r|| }| j |¡ d S rN )ry Údebugr¼ r r r rª s zRefactoringTool.log_debugc C s dS )zTCalled with the old version, new version, and filename of a refactored file.Nr )r• Úold_textÚnew_textÚfilenameÚequalr r r Úprint_output s zRefactoringTool.print_outputc C s8 |D ]}t j |¡r| |||¡ q| |||¡ qdS )z)Refactor a list of files and directories.N)ÚosÚpathÚisdirÚrefactor_dirÚ refactor_file)r• ÚitemsÚwriteÚ doctests_onlyÚdir_or_filer r r Úrefactor s üzRefactoringTool.refactorc C sš t jd }t |¡D ]@\}}}| d|¡ | ¡ | ¡ |D ]}| d¡s>t j |¡d |kr>t j ||¡} | | ||¡ qdd„ |D ƒ|dd…<