관리-도구
편집 파일: expand.cpython-311.pyc
� ,�Re�? � �( � d Z ddlZddlZddlZddlZddlZddlZddlZddlm Z ddl mZ ddlm Z ddlmZ ddlmZmZmZmZmZmZmZmZmZmZmZmZ ddlmZ dd lmZ dd l m!Z! ddl"m#Z$ erdd l%m&Z& ddl'm(Z( ddl)m*Z* ej+ Z,ee-ej. f Z/ ed� � Z0 edd�� � Z1 G d� d� � Z2 d@dee- dee/ dee- fd�Z3d@dee-e4ee/ f de-fd�Z5dee/ dee/ fd�Z6dee4e/f de-fd�Z7de/de-fd�Z8 dAd e-d!eee-e-f dee/ fd"�Z9d#e-d$ee/ de fd%�Z:d&e d#e-defd'�Z;d#e-d!eee-e-f de/dee/ee- e-f fd(�Z< dAd)e-d!eee-e-f dee/ defd*�Z= dAd+ee-e-f d!eee-e-f dee/ dee-ef fd,�Z>dddd-�d.eee-e-f dee/ dee- fd/�Z?d0e/d1e/de-fd2�Z@d3eeeee-eAf e-f de-fd4�ZBd5eCdeCfd6�ZD d@d7eeEeCf dee/ deee-ee- f fd8�ZFdBd:e-dee-eCf fd;�ZG G d<� d=� � ZH G d>� d?ee0e1f � � ZIdS )Cai Utility functions to expand configuration directives or special values (such glob patterns). We can split the process of interpreting configuration files into 2 steps: 1. The parsing the file contents from strings to value objects that can be understand by Python (for example a string with a comma separated list of keywords into an actual Python list of strings). 2. The expansion (or post-processing) of these values according to the semantics ``setuptools`` assign to them (for example a configuration field with the ``file:`` directive should be expanded from a list of file paths to a single string with the contents of those files concatenated) This module focus on the second step, and therefore allow sharing the expansion functions among several configuration file formats. **PRIVATE MODULE**: API reserved for setuptools internal usage only. � N)�iglob)�ConfigParser)� ModuleSpec)�chain)� TYPE_CHECKING�Callable�Dict�Iterable�Iterator�List�Mapping�Optional�Tuple�TypeVar�Union�cast)�Path)� ModuleType)�DistutilsOptionError� )� same_path)�Distribution)�ConfigDiscovery)�DistributionMetadata�_K�_VT)� covariantc �d � e Zd ZdZdedefd�Zdeee j e j f fd�Zd� ZdS ) �StaticModulez>Proxy to a module object that avoids executing arbitrary code.�name�specc �� � t j t j |j � � � � � � � }t | � � � t � � � � | ` d S �N) �ast�parse�pathlibr �origin� read_bytes�vars�update�locals�self)r, r r! �modules ��/builddir/build/BUILDROOT/alt-python311-setuptools-65.6.3-2.el8.x86_64/opt/alt/python311/lib/python3.11/site-packages/setuptools/config/expand.py�__init__zStaticModule.__init__B sP � ���7�<���4�4�?�?�A�A�B�B���T� � ���&�(�(�#�#�#��I�I�I� �returnc # �� �K � | j j D ]g�t �t j � � r�fd��j D � � E d {V �� �6t �t j � � r�j r�j �j fV � �hd S )Nc 3 �* �K � | ] }|�j fV � �d S r# ��value)�.0�target� statements �r. � <genexpr>z1StaticModule._find_assignments.<locals>.<genexpr>J s* �� � � �V�V�&�V�Y�_�5�V�V�V�V�V�Vr0 ) r- �body� isinstancer$ �Assign�targets� AnnAssignr5 r7 )r, r8 s @r. �_find_assignmentszStaticModule._find_assignmentsG s� �� � � ���)� :� :�I��)�S�Z�0�0� :�V�V�V�V�I�DU�V�V�V�V�V�V�V�V�V�V�V��I�s�}�5�5� :�)�/� :� �'���9�9�9�9�� :� :r0 c � �� t �fd�| � � � D � � � � S # t $ r}t | j � d�� �� � |�d}~ww xY w)zHAttempt to load an attribute "statically", via :func:`ast.literal_eval`.c 3 � �K � | ]@\ }}t |t j � � r!|j �k �*t j |� � V � �Ad S r# )r; r$ �Name�id�literal_eval)r6 r7 r5 �attrs �r. r9 z+StaticModule.__getattr__.<locals>.<genexpr>Q sa �� � � � � �!�F�E��f�c�h�/�/�� 5;�I��4E�4E� � ��'�'�4E�4E�4E�4E�� r0 z has no attribute N)�nextr? � Exception�AttributeErrorr )r, rE �es ` r. �__getattr__zStaticModule.__getattr__N s� �� � P�� � � � �%)�%;�%;�%=�%=�� � � � � �� � P� P� P� �D�I�!G�!G��!G�!G�H�H�a�O����� P���s �,0 � A�A�AN) �__name__� __module__�__qualname__�__doc__�strr r/ r r r$ �ASTr? rJ � r0 r. r r ? s~ � � � � � �H�H��S� � � � � � � :�8�E�#�'�3�7�2B�,C�#D� :� :� :� :� P� P� P� P� Pr0 r �patterns�root_dirr1 c � ��� h d�}g }�pt j � � �| D ]�t �fd�|D � � � � r{t j � t j � ��� � � � }|� t �fd�t |d�� � D � � � � � � ��t j � ��� � � t j d� � }|� |� � ��|S )a Expand the list of glob patterns, but preserving relative paths. :param list[str] patterns: List of glob patterns :param str root_dir: Path to which globs should be relative (current directory by default) :rtype: list > �*�{�}�?�[�]c 3 � �K � | ]}|�v V � � d S r# rQ )r6 �charr5 s �r. r9 z glob_relative.<locals>.<genexpr>j s'