Your IP : 18.118.33.239


Current Path : /opt/alt/python36/lib/python3.6/site-packages/setuptools/__pycache__/
Upload File :
Current File : //opt/alt/python36/lib/python3.6/site-packages/setuptools/__pycache__/config.cpython-36.pyc

3

K�Re�?�@s�ddlmZmZddlZddlZddlZddlmZddlm	Z	ddl
mZddlm
Z
mZddlmZdd	d
�Zdd�Zdd
d�ZGdd�de�ZGdd�de�ZGdd�de�ZdS)�)�absolute_import�unicode_literalsN)�defaultdict)�partial)�
import_module)�DistutilsOptionError�DistutilsFileError)�string_typesFc	Cs�ddlm}m}tjj|�}tjj|�s4td|��tj�}tj	tjj
|��zJ|�}|rb|j�ng}||krx|j|�|j
||d�t||j|d�}Wdtj	|�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_errorsN)Zsetuptools.distr
r�os�path�abspath�isfiler�getcwd�chdir�dirname�find_config_files�append�parse_config_files�parse_configuration�command_options�configuration_to_dict)	�filepathZfind_othersr
r
rZcurrent_directory�distr�handlers�r��/builddir/build/BUILDROOT/alt-python36-setuptools-38.5.2-7.el8.x86_64/opt/alt/python36/lib/python3.6/site-packages/setuptools/config.py�read_configuration
s$

r cCsltt�}x^|D]V}|j}|j}xD|jD]:}t|d|d�}|dkrNt||�}n|�}||||<q&WqW|S)z�Returns configuration data gathered by given handlers as a dict.

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

    :rtype: dict
    zget_%sN)r�dict�section_prefix�
target_obj�set_options�getattr)rZconfig_dict�handlerZ	obj_aliasr#�option�getter�valuerrrr<s
rcCs2t|j||�}|j�t|||�}|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
    )�ConfigMetadataHandler�metadata�parse�ConfigOptionsHandler)�distributionrr
�meta�optionsrrrrYs
rc@s�eZdZdZdZiZd!dd�Zedd��Zdd	�Z	e
d"dd��Ze
d
d��Ze
dd��Z
e
dd��Zedd��Zedd��Ze
dd��Ze
dd��Ze
d#dd��Zdd�Zdd �ZdS)$�
ConfigHandlerz1Handles metadata supplied in configuration files.NFcCsbi}|j}x:|j�D].\}}|j|�s(q|j|d�jd�}|||<qW||_||_||_g|_dS)N��.)	r"�items�
startswith�replace�stripr
r#�sectionsr$)�selfr#r0r
r8r"�section_name�section_optionsrrr�__init__�s
zConfigHandler.__init__cCstd|jj��dS)z.Metadata item name to parser function mapping.z!%s must provide .parsers propertyN)�NotImplementedError�	__class__�__name__)r9rrr�parsers�szConfigHandler.parsersc	Cs�t�}|j}|jj||�}t|||�}||kr6t|��|r>dSd}|jj|�}|r�y||�}Wn tk
r~d}|jsz�YnX|r�dSt|d|d�}|dkr�t	|||�n||�|j
j|�dS)NFTzset_%s)�tupler#�aliases�getr%�KeyErrorr@�	Exceptionr
�setattrr$r)	r9Zoption_namer)�unknownr#Z
current_valueZskip_option�parser�setterrrr�__setitem__�s0zConfigHandler.__setitem__�,cCs8t|t�r|Sd|kr |j�}n
|j|�}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|]}|j�r|j��qSr)r7)�.0�chunkrrr�
<listcomp>�sz-ConfigHandler._parse_list.<locals>.<listcomp>)�
isinstance�list�
splitlines�split)�clsr)�	separatorrrr�_parse_list�s



zConfigHandler._parse_listcCsTd}i}xF|j|�D]8}|j|�\}}}||kr<td|��|j�||j�<qW|S)zPRepresents value as a dict.

        :param value:
        :rtype: dict
        �=z(Unable to parse option value to dict: %s)rV�	partitionrr7)rTr)rU�result�line�key�sep�valrrr�_parse_dict�s
zConfigHandler._parse_dictcCs|j�}|dkS)zQRepresents value as boolean.

        :param value:
        :rtype: bool
        �1�true�yes)r_r`ra)�lower)rTr)rrr�_parse_bool�szConfigHandler._parse_boolcs\d}t|t�s|S|j|�s |S|t|�d�}dd�|jd�D�}dj�fdd�|D��S)aiRepresents 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: LICENSE
            file: README.rst, CHANGELOG.md, src/file.txt

        :param str value:
        :rtype: str
        zfile:Ncss|]}tjj|j��VqdS)N)rrrr7)rMrrrr�	<genexpr>sz,ConfigHandler._parse_file.<locals>.<genexpr>rKrLc3s2|]*}�j|�sdrtjj|�r�j|�VqdS)TN)�
_assert_localrrr�
_read_file)rMr)rTrrrd	s)rPr	r5�lenrS�join)rTr)Zinclude_directive�specZ	filepathsr)rTr�_parse_file�s


zConfigHandler._parse_filecCs|jtj��std|��dS)Nz#`file:` directive can not access %s)r5rrr)rrrrreszConfigHandler._assert_localc	Cs"tj|dd��
}|j�SQRXdS)Nzutf-8)�encoding)�io�open�read)r�frrrrfszConfigHandler._read_filecCs�d}|j|�s|S|j|d�j�jd�}|j�}dj|�}|p@d}tjjdt	j
��zt|�}t||�}Wdtjdd�t_X|S)z�Represents value as a module attribute.

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

        :param str value:
        :rtype: str
        zattr:r2r3r<rN�)
r5r6r7rS�poprh�sysr�insertrrrr%)rTr)Zattr_directiveZ
attrs_path�	attr_name�module_name�modulerrr�_parse_attrs

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|}x�D]}||�}q
W|S)Nr)r)�parsed�method)�
parse_methodsrrr,Bs
z1ConfigHandler._get_parser_compound.<locals>.parser)rTrzr,r)rzr�_get_parser_compound9s	z"ConfigHandler._get_parser_compoundcCs:i}|pdd�}x$|j�D]\}\}}||�||<qW|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|S)Nr)r]rrr�<lambda>Wsz6ConfigHandler._parse_section_to_dict.<locals>.<lambda>)r4)rTr;Z
values_parserr)r[�_r]rrr�_parse_section_to_dictLs

z$ConfigHandler._parse_section_to_dictcCs@x:|j�D].\}\}}y|||<Wq
tk
r6Yq
Xq
WdS)zQParses configuration file section.

        :param dict section_options:
        N)r4rD)r9r;�namer}r)rrr�
parse_section\s
zConfigHandler.parse_sectioncCsfx`|jj�D]R\}}d}|r$d|}t|d|jdd�d�}|dkrVtd|j|f��||�qWdS)zTParses configuration file items from one
        or more related sections.

        r2z_%szparse_section%sr3�__Nz0Unsupported distribution option section: [%s.%s])r8r4r%r6rr")r9r:r;Zmethod_postfixZsection_parser_methodrrrr,hszConfigHandler.parse)F)rK)N)r?�
__module__�__qualname__�__doc__r"rBr<�propertyr@rJ�classmethodrVr^rcrj�staticmethodrerfrwr{r~r�r,rrrrr1ss&
&
 r1c@s6eZdZdZddddd�ZdZedd	��Zd
d�ZdS)
r*r+�url�description�classifiers�	platforms)Z	home_page�summary�
classifier�platformFcCs8|j}|j}|j}||||||j||�||||j|d�S)z.Metadata item name to parser function mapping.)r��keywords�provides�requires�	obsoletesr��licenser��long_description�version�project_urls)rVrjr^r{�_parse_version)r9�
parse_listZ
parse_file�
parse_dictrrrr@�s
zConfigMetadataHandler.parserscCsJ|j|�}t|�r|�}t|t�sFt|d�r>djtt|��}nd|}|S)zSParses `version` option value.

        :param value:
        :rtype: str

        �__iter__r3z%s)rw�callablerPr	�hasattrrh�map�str)r9r)r�rrrr��s


z$ConfigMetadataHandler._parse_versionN)	r?r�r�r"rBZstrict_moder�r@r�rrrrr*�sr*c@sTeZdZdZedd��Zdd�Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�ZdS)r-r0cCsL|j}t|jdd�}|j}|j}|||||||||||||||j|j|d�S)z.Metadata item name to parser function mapping.�;)rU)Zzip_safeZuse_2to3Zinclude_package_data�package_dirZuse_2to3_fixersZuse_2to3_exclude_fixersZconvert_2to3_doctests�scriptsZeager_resourcesZdependency_linksZnamespace_packagesZinstall_requiresZsetup_requiresZ
tests_require�packages�entry_points�
py_modules)rVrrcr^�_parse_packagesrj)r9r�Zparse_list_semicolonZ
parse_boolr�rrrr@�s*zConfigOptionsHandler.parserscCsBd}|j|�s|j|�S|j|jjdi��}ddlm}|f|�S)zTParses `packages` option value.

        :param value:
        :rtype: list
        zfind:z
packages.findr)�
find_packages)r5rV�parse_section_packages__findr8rC�
setuptoolsr�)r9r)Zfind_directive�find_kwargsr�rrrr��s

z$ConfigOptionsHandler._parse_packagescsT|j||j�}dddg�t�fdd�|j�D��}|jd�}|dk	rP|d|d<|S)z�Parses `packages.find` configuration file section.

        To be used in conjunction with _parse_packages().

        :param dict section_options:
        �where�include�excludecs$g|]\}}|�kr|r||f�qSrr)rM�k�v)�
valid_keysrrrO�szEConfigOptionsHandler.parse_section_packages__find.<locals>.<listcomp>Nr)r~rVr!r4rC)r9r;Zsection_datar�r�r)r�rr��s


z1ConfigOptionsHandler.parse_section_packages__findcCs|j||j�}||d<dS)z`Parses `entry_points` configuration file section.

        :param dict section_options:
        r�N)r~rV)r9r;rxrrr�parse_section_entry_pointssz/ConfigOptionsHandler.parse_section_entry_pointscCs.|j||j�}|jd�}|r*||d<|d=|S)N�*r2)r~rVrC)r9r;rx�rootrrr�_parse_package_datas
z(ConfigOptionsHandler._parse_package_datacCs|j|�|d<dS)z`Parses `package_data` configuration file section.

        :param dict section_options:
        �package_dataN)r�)r9r;rrr�parse_section_package_datasz/ConfigOptionsHandler.parse_section_package_datacCs|j|�|d<dS)zhParses `exclude_package_data` configuration file section.

        :param dict section_options:
        Zexclude_package_dataN)r�)r9r;rrr�"parse_section_exclude_package_datasz7ConfigOptionsHandler.parse_section_exclude_package_datacCs"t|jdd�}|j||�|d<dS)zbParses `extras_require` configuration file section.

        :param dict section_options:
        r�)rUZextras_requireN)rrVr~)r9r;r�rrr�parse_section_extras_require%sz1ConfigOptionsHandler.parse_section_extras_requireN)
r?r�r�r"r�r@r�r�r�r�r�r�r�rrrrr-�s
r-)FF)F)�
__future__rrrlrrr�collectionsr�	functoolsr�	importlibr�distutils.errorsrrZsetuptools.extern.sixr	r rr�objectr1r*r-rrrr�<module>s 
.
;

?>