Your IP : 18.117.184.236


Current Path : /opt/alt/python35/lib/python3.5/site-packages/setuptools/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib/python3.5/site-packages/setuptools/__pycache__/config.cpython-35.pyc



�Re�?�@sddlmZmZddlZddlZddlZddlmZddlm	Z	ddl
mZmZddl
mZddlmZddd	d
�Zdd�Zdd
d�ZGdd�de�ZGdd�de�ZGdd�de�ZdS)�)�absolute_import�unicode_literalsN)�defaultdict)�partial)�DistutilsOptionError�DistutilsFileError)�
import_module)�string_typesFc	Cs�ddlm}m}tjj|�}tjj|�sJtd|��tj�}tj	tjj
|��zi|�}|r�|j�ng}||kr�|j|�|j
|d|�t||jd|�}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-python35-setuptools-36.3.0-4.el8.x86_64/opt/alt/python35/lib/python3.5/site-packages/setuptools/config.py�read_configuration
s$
	

r cCs�tt�}x|D]w}|j}|j}x\|jD]Q}t|d|d�}|dkrot||�}n	|�}||||<q5WqW|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
			rcCsEt|j||�}|j�t|||�}|j�||gS)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@seZdZdZdZiZddd�Zedd��Zdd	�Z	e
d
dd��Ze
d
d��Ze
dd��Z
e
dd��Zedd��Zedd��Ze
dd��Ze
dd��Ze
ddd��Zdd�Zdd �ZdS)!�
ConfigHandlerz1Handles metadata supplied in configuration files.NFcCs�i}|j}xQ|j�D]C\}}|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|||�}||krQt|��|r[dSd}|jj|�}|r�y||�}Wn$tk
r�d}|js��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__�,cCsNt|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
        �
cSs(g|]}|j�r|j��qSr)r7)�.0�chunkrrr�
<listcomp>�s	z-ConfigHandler._parse_list.<locals>.<listcomp>)�
isinstance�list�
splitlines�split)�clsr)�	separatorrrr�_parse_list�s
zConfigHandler._parse_listcCstd}i}xa|j|�D]P}|j|�\}}}||krVtd|��|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�szConfigHandler._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>rKrLc3sE|];}�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�szConfigHandler._parse_filecCs)|jtj��s%td|��dS)Nz#`file:` directive can not access %s)r5rrr)rrrrreszConfigHandler._assert_localc	Cs-tj|dd��}|j�SWdQRXdS)N�encodingzutf-8)�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_compoundcCsOi}|pdd�}x0|j�D]"\}\}}||�||<q%W|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CsJxC|j�D]5\}\}}y|||<Wq
tk
rAYq
Xq
WdS)zQParses configuration file section.

        :param dict section_options:
        N)r4rD)r9r;�namer}r)rrr�
parse_section\s

zConfigHandler.parse_sectioncCs�x�|jj�D]s\}}d}|r2d|}t|d|jdd�d�}|dkrytd|j|f��||�qWdS)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,hs
	zConfigHandler.parse)r?�
__module__�__qualname__�__doc__r"rBr<�propertyr@rJ�classmethodrVr^rcrj�staticmethodrerfrwr{r~r�r,rrrrr1ss&&
 r1c@sXeZdZdZdddddddd	iZd
Zedd��Zd
d�ZdS)r*r+Z	home_page�url�summary�description�
classifier�classifiers�platform�	platformsFcCsa|j}|j}d|d|d|d|d|d|j||�d|d|d	|d
|ji
S)z.Metadata item name to parser function mapping.r��keywords�provides�requires�	obsoletesr��licenser��long_description�version)rVrjr{�_parse_version)r9�
parse_listZ
parse_filerrrr@�s		zConfigMetadataHandler.parserscCsk|j|�}t|�r$|�}t|t�sgt|d�r]djtt|��}n
d|}|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@s|eZdZdZedd��Zdd�Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�ZdS)r-r0c"Cs�|j}t|jdd�}|j}|j}d|d|d|d|d|d|d	|d
|d|d|d
|d|d|d|d|jd|jd|iS)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_boolZ
parse_dictrrrr@�s*					zConfigOptionsHandler.parserscCsZd}|j|�s"|j|�S|j|jjdi��}ddlm}||�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_packagescsv|j||j�}dddg�t�fdd�|j�D��}|jd�}|dk	rr|d|d<|S)z�Parses `packages.find` configuration file section.

        To be used in conjunction with _parse_packages().

        :param dict section_options:
        �where�include�excludecs4g|]*\}}|�kr|r||f�qSrr)rM�k�v)�
valid_keysrrrO�s	zEConfigOptionsHandler.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:
        rUr�Zextras_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-)�
__future__rrrlrrr�collectionsr�	functoolsr�distutils.errorsrrZsetuptools.py26compatrZsetuptools.extern.sixr	r rr�objectr1r*r-rrrr�<module>s.�9

?>