Your IP : 18.223.159.143


Current Path : /usr/lib/python3.8/site-packages/setuptools/__pycache__/
Upload File :
Current File : //usr/lib/python3.8/site-packages/setuptools/__pycache__/config.cpython-38.pyc

U

�Qab6P�@s�ddlmZmZddlZddlZddlZddlZddlZddlm	Z	ddlm
Z
ddlmZddlm
Z
ddlmZmZddlmZmZdd	lmZdd
lmZmZeZddd
�Zdd�Zdd�Zddd�ZGdd�d�ZGdd�de�Z Gdd�de�Z!dS)�)�absolute_import�unicode_literalsN)�defaultdict)�partial��wraps)�
import_module)�DistutilsOptionError�DistutilsFileError)�
LegacyVersion�parse)�SpecifierSet)�string_types�PY3Fc		Cs�ddlm}m}tj�|�}tj�|�s4td|��t��}t�	tj�
|��zJ|�}|rb|��ng}||krx|�|�|j
||d�t||j|d�}W5t�	|�Xt|�S)a,Read given configuration file and returns options from it as a dict.

    :param str|unicode filepath: Path to configuration file
        to get options from.

    :param bool find_others: Whether to search for other configuration files
        which could be on in various places.

    :param bool ignore_option_errors: Whether to silently ignore
        options, values of which could not be resolved (e.g. due to exceptions
        in directives such as file:, attr:, etc.).
        If False exceptions are propagated as expected.

    :rtype: dict
    r)�Distribution�
_Distributionz%Configuration file %s does not exist.)�	filenames)�ignore_option_errors)Zsetuptools.distrr�os�path�abspath�isfiler
�getcwd�chdir�dirnameZfind_config_files�appendZparse_config_files�parse_configuration�command_options�configuration_to_dict)	�filepathZfind_othersrrrZcurrent_directoryZdistr�handlers�r!�5/usr/lib/python3.8/site-packages/setuptools/config.py�read_configurations*�
�
r#cCs.djft��}t�t||�}t|||�}|�S)z�
    Given a target object and option key, get that option from
    the target object, either through a get_{key} method or
    from an attribute directly.
    z	get_{key})�format�locals�	functoolsr�getattr)�
target_obj�keyZgetter_nameZby_attribute�getterr!r!r"�_get_optionEsr+cCs<tt�}|D]*}|jD]}t|j|�}|||j|<qq|S)z�Returns configuration data gathered by given handlers as a dict.

    :param list[ConfigHandler] handlers: Handlers list,
        usually from parse_configuration()

    :rtype: dict
    )r�dict�set_optionsr+r(�section_prefix)r Zconfig_dictZhandlerZoption�valuer!r!r"rQs
rcCs6t|||�}|��t|j|||j�}|��||fS)a�Performs additional parsing of configuration options
    for a distribution.

    Returns a list of used option handlers.

    :param Distribution distribution:
    :param dict command_options:
    :param bool ignore_option_errors: Whether to silently ignore
        options, values of which could not be resolved (e.g. due to exceptions
        in directives such as file:, attr:, etc.).
        If False exceptions are propagated as expected.
    :rtype: list
    )�ConfigOptionsHandlerr�ConfigMetadataHandler�metadata�package_dir)Zdistributionrr�options�metar!r!r"rcs��rc@s�eZdZdZdZiZd%dd�Zedd��Zdd	�Z	e
d&dd��Ze
d
d��Ze
dd��Z
e
dd��Ze
dd��Zedd��Zedd��Ze
d'dd��Ze
dd��Ze
d(dd��Zdd �Zd!d"�Zd#d$�ZdS))�
ConfigHandlerz1Handles metadata supplied in configuration files.NFcCs^i}|j}|��D].\}}|�|�s&q|�|d��d�}|||<q||_||_||_g|_dS)N��.)	r.�items�
startswith�replace�striprr(�sectionsr-)�selfr(r4rr=r.�section_name�section_optionsr!r!r"�__init__�s

zConfigHandler.__init__cCstd|jj��dS)�.Metadata item name to parser function mapping.z!%s must provide .parsers propertyN)�NotImplementedError�	__class__�__name__)r>r!r!r"�parsers�s
�zConfigHandler.parsersc	Cs�t�}|j}|j�||�}t|||�}||kr6t|��|r>dSd}|j�|�}|r�z||�}Wn tk
r~d}|jsz�YnX|r�dSt|d|d�}|dkr�t	|||�n||�|j
�|�dS)NFTzset_%s)�tupler(�aliases�getr'�KeyErrorrF�	Exceptionr�setattrr-r)	r>Zoption_namer/�unknownr(Z
current_valueZskip_option�parser�setterr!r!r"�__setitem__�s0zConfigHandler.__setitem__�,cCs8t|t�r|Sd|kr |��}n
|�|�}dd�|D�S)z�Represents value as a list.

        Value is split either by separator (defaults to comma) or by lines.

        :param value:
        :param separator: List items separator character.
        :rtype: list
        �
cSsg|]}|��r|���qSr!)r<)�.0�chunkr!r!r"�
<listcomp>�sz-ConfigHandler._parse_list.<locals>.<listcomp>)�
isinstance�list�
splitlines�split)�clsr/�	separatorr!r!r"�_parse_list�s



zConfigHandler._parse_listcCsPd}i}|�|�D]8}|�|�\}}}||kr:td|��|��||��<q|S)zPRepresents value as a dict.

        :param value:
        :rtype: dict
        �=z(Unable to parse option value to dict: %s)r\�	partitionr	r<)rZr/r[�result�liner)�sep�valr!r!r"�_parse_dict�s�zConfigHandler._parse_dictcCs|��}|dkS)zQRepresents value as boolean.

        :param value:
        :rtype: bool
        )�1�trueZyes)�lower)rZr/r!r!r"�_parse_bool�szConfigHandler._parse_boolcs�fdd�}|S)z�Returns a parser function to make sure field inputs
        are not files.

        Parses a value after getting the key so error messages are
        more informative.

        :param key:
        :rtype: callable
        cs d}|�|�rtd�����|S)N�file:zCOnly strings are accepted for the {0} field, files are not accepted)r:�
ValueErrorr$)r/Zexclude_directive�r)r!r"rNs
��z3ConfigHandler._exclude_files_parser.<locals>.parserr!)rZr)rNr!rjr"�_exclude_files_parser�sz#ConfigHandler._exclude_files_parsercs\d}t|t�s|S|�|�s |S|t|�d�}dd�|�d�D�}d��fdd�|D��S)aORepresents value as a string, allowing including text
        from nearest files using `file:` directive.

        Directive is sandboxed and won't reach anything outside
        directory with setup.py.

        Examples:
            file: README.rst, CHANGELOG.md, src/file.txt

        :param str value:
        :rtype: str
        rhNcss|]}tj�|���VqdS�N)rrrr<�rSrr!r!r"�	<genexpr>%sz,ConfigHandler._parse_file.<locals>.<genexpr>rQrRc3s.|]&}��|�stj�|�r��|�VqdS)TN)�
_assert_localrrr�
_read_filerm�rZr!r"rn&s

�)rVrr:�lenrY�join)rZr/Zinclude_directive�specZ	filepathsr!rqr"�_parse_files

�zConfigHandler._parse_filecCs|�t���std|��dS)Nz#`file:` directive can not access %s)r:rrr	)rr!r!r"ro-s�zConfigHandler._assert_localc
Cs.tj|dd��}|��W5QR�SQRXdS)Nzutf-8)�encoding)�io�open�read)r�fr!r!r"rp3szConfigHandler._read_filec	Cs�d}|�|�s|S|�|d����d�}|��}d�|�}|p@d}t��}|r�|d|kr�||d}|�dd�}	t	|	�dkr�tj
�t��|	d�}|	d}q�|}nd|kr�tj
�t��|d�}tj
�d|�zt
|�}
t|
|�}W5tj
dd�t_
X|S)	z�Represents value as a module attribute.

        Examples:
            attr: package.attr
            attr: package.module.attr

        :param str value:
        :rtype: str
        zattr:r7r8rAr�/�N)r:r;r<rY�poprsrr�rsplitrrr�sys�insertrr')rZr/r3Zattr_directiveZ
attrs_pathZ	attr_nameZmodule_name�parent_pathZcustom_path�parts�moduler!r!r"�_parse_attr8s0


zConfigHandler._parse_attrcs�fdd�}|S)z�Returns parser function to represents value as a list.

        Parses a value applying given methods one after another.

        :param parse_methods:
        :rtype: callable
        cs|}�D]}||�}q|Srlr!)r/�parsed�method��
parse_methodsr!r"rns
z1ConfigHandler._get_parser_compound.<locals>.parser!)rZr�rr!r�r"�_get_parser_compoundes	z"ConfigHandler._get_parser_compoundcCs6i}|pdd�}|��D]\}\}}||�||<q|S)z�Parses section options into a dictionary.

        Optionally applies a given parser to values.

        :param dict section_options:
        :param callable values_parser:
        :rtype: dict
        cSs|Srlr!)rbr!r!r"�<lambda>��z6ConfigHandler._parse_section_to_dict.<locals>.<lambda>)r9)rZr@Z
values_parserr/r)�_rbr!r!r"�_parse_section_to_dictxs

z$ConfigHandler._parse_section_to_dictc	Cs<|��D].\}\}}z|||<Wqtk
r4YqXqdS)zQParses configuration file section.

        :param dict section_options:
        N)r9rJ)r>r@�namer�r/r!r!r"�
parse_section�s
zConfigHandler.parse_sectioncCsb|j��D]R\}}d}|r"d|}t|d|�dd�d�}|dkrTtd|j|f��||�q
dS)zTParses configuration file items from one
        or more related sections.

        r7z_%szparse_section%sr8�__Nz0Unsupported distribution option section: [%s.%s])r=r9r'r;r	r.)r>r?r@Zmethod_postfixZsection_parser_methodr!r!r"r�s"���zConfigHandler.parsecst�����fdd��}|S)z� this function will wrap around parameters that are deprecated

        :param msg: deprecation message
        :param warning_class: class of warning exception to be raised
        :param func: function to be wrapped around
        cst�����||�Srl)�warnings�warn)�args�kwargs��func�msg�
warning_classr!r"�config_handler�sz@ConfigHandler._deprecated_config_handler.<locals>.config_handlerr)r>r�r�r�r�r!r�r"�_deprecated_config_handler�sz(ConfigHandler._deprecated_config_handler)F)rQ)N)N)rE�
__module__�__qualname__�__doc__r.rHrA�propertyrFrP�classmethodr\rcrgrkru�staticmethodrorpr�r�r�r�rr�r!r!r!r"r6~s<

&

	



,
r6csHeZdZdZddddd�ZdZd�fd	d
�	Zedd��Zd
d�Z	�Z
S)r1r2Zurl�description�classifiers�	platforms)Z	home_pageZsummaryZ
classifier�platformFNcstt|��|||�||_dSrl)�superr1rAr3)r>r(r4rr3�rDr!r"rA�s�zConfigMetadataHandler.__init__cCsL|j}|j}|j}|j}||||�|dt�||�||�|d�|||j|d�S)rBz[The requires parameter is deprecated, please use install_requires for runtime dependencies.�license)r��keywordsZprovidesZrequiresZ	obsoletesr�r�r�Zlong_description�versionZproject_urls)r\rurcrkr��DeprecationWarningr��_parse_version)r>�
parse_listZ
parse_file�
parse_dictZexclude_files_parserr!r!r"rF�s(�
�zConfigMetadataHandler.parserscCs�|�|�}||krB|��}tt|�t�r>d}t|jft����|S|�||j	�}t
|�r^|�}t|t�s�t|d�r�d�
tt|��}nd|}|S)zSParses `version` option value.

        :param value:
        :rtype: str

        zCVersion loaded from {value} does not comply with PEP 440: {version}�__iter__r8z%s)rur<rVrrr	r$r%r�r3�callabler�hasattrrs�map�str)r>r/r�Ztmplr!r!r"r��s 
�

z$ConfigMetadataHandler._parse_version)FN)rEr�r�r.rHZstrict_moderAr�rFr��
__classcell__r!r!r�r"r1�s��
r1c@s\eZdZdZedd��Zdd�Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dS)r0r4cCsN|j}t|jdd�}|j}|j}|||||||||||||||j|j|td�S)rB�;�r[)Zzip_safeZuse_2to3Zinclude_package_datar3Zuse_2to3_fixersZuse_2to3_exclude_fixersZconvert_2to3_doctestsZscriptsZeager_resourcesZdependency_linksZnamespace_packagesZinstall_requiresZsetup_requiresZ
tests_requireZpackages�entry_pointsZ
py_modulesZpython_requires)r\rrgrc�_parse_packagesrur
)r>r�Zparse_list_semicolonZ
parse_boolr�r!r!r"rFs.�zConfigOptionsHandler.parserscCszddg}|��}||kr"|�|�S||dk}|r>ts>td��|�|j�di��}|rdddlm}nddlm	}|f|�S)	zTParses `packages` option value.

        :param value:
        :rtype: list
        zfind:zfind_namespace:r|z8find_namespace: directive is unsupported on Python < 3.3z
packages.findr)�find_namespace_packages)�
find_packages)
r<r\rr	�parse_section_packages__findr=rIZ
setuptoolsr�r�)r>r/Zfind_directivesZ
trimmed_valueZfindns�find_kwargsr�r!r!r"r�1s 
��z$ConfigOptionsHandler._parse_packagescsT|�||j�}dddg�t�fdd�|��D��}|�d�}|dk	rP|d|d<|S)z�Parses `packages.find` configuration file section.

        To be used in conjunction with _parse_packages().

        :param dict section_options:
        �whereZinclude�excludecs$g|]\}}|�kr|r||f�qSr!r!�rS�k�v�Z
valid_keysr!r"rUZszEConfigOptionsHandler.parse_section_packages__find.<locals>.<listcomp>Nr)r�r\r,r9rI)r>r@Zsection_datar�r�r!r�r"r�Ms�
�
z1ConfigOptionsHandler.parse_section_packages__findcCs|�||j�}||d<dS)z`Parses `entry_points` configuration file section.

        :param dict section_options:
        r�N)r�r\�r>r@r�r!r!r"�parse_section_entry_pointsbsz/ConfigOptionsHandler.parse_section_entry_pointscCs.|�||j�}|�d�}|r*||d<|d=|S)N�*r7)r�r\rI)r>r@r��rootr!r!r"�_parse_package_datajs
z(ConfigOptionsHandler._parse_package_datacCs|�|�|d<dS)z`Parses `package_data` configuration file section.

        :param dict section_options:
        Zpackage_dataN�r��r>r@r!r!r"�parse_section_package_datatsz/ConfigOptionsHandler.parse_section_package_datacCs|�|�|d<dS)zhParses `exclude_package_data` configuration file section.

        :param dict section_options:
        Zexclude_package_dataNr�r�r!r!r"�"parse_section_exclude_package_data{s�z7ConfigOptionsHandler.parse_section_exclude_package_datacCs"t|jdd�}|�||�|d<dS)zbParses `extras_require` configuration file section.

        :param dict section_options:
        r�r�Zextras_requireN)rr\r�)r>r@r�r!r!r"�parse_section_extras_require�s
�z1ConfigOptionsHandler.parse_section_extras_requirecCs(|�||j�}dd�|��D�|d<dS)z^Parses `data_files` configuration file section.

        :param dict section_options:
        cSsg|]\}}||f�qSr!r!r�r!r!r"rU�szAConfigOptionsHandler.parse_section_data_files.<locals>.<listcomp>Z
data_filesN)r�r\r9r�r!r!r"�parse_section_data_files�sz-ConfigOptionsHandler.parse_section_data_filesN)rEr�r�r.r�rFr�r�r�r�r�r�r�r�r!r!r!r"r0s

	r0)FF)F)"Z
__future__rrrwrrr�r&�collectionsrrr�	importlibrZdistutils.errorsr	r
Z#setuptools.extern.packaging.versionrrZ&setuptools.extern.packaging.specifiersr
Zsetuptools.extern.sixrr�typeZ
__metaclass__r#r+rrr6r1r0r!r!r!r"�<module>s4�
/�
?U

?>