관리-도구
편집 파일: refactor.cpython-310.pyc
o 6��fsk � @ 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 <guido@python.org>� 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__�pkgutilZiter_modules�__path__� startswith�append)Z fixer_pkgZ remove_prefixZpkgZ fix_names�finder�nameZispkg� r �7/opt/alt/python310/lib64/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 ZNodePatternZLeafPattern�typer ZNegatedPatternZcontent�_get_head_typesZWildcardPattern�set�update� Exception)Zpat�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 Z_accept_typer r �python_grammarZ symbol2number�values�tokens�extend�dict)Z fixer_listZ head_nodesZevery�fixerZheadsZ node_typer r r �_get_headnode_dictK s( �� �r2 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�Zpkg_namer r � <listcomp>h s �z+get_fixers_from_package.<locals>.<listcomp>F)r r7 r r7 r �get_fixers_from_packaged s �r9 c C s | S �Nr )�objr r r � _identityk s r<