Hacked By AnonymousFox

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

3

9��fVF�@s�ddlmZmZddlZddlZddlZddlmZddlm	Z	ddl
mZddlm
Z
mZddlmZmZddlmZdd
d�Zdd
�Zddd�ZGdd�de�ZGdd�de�ZGdd�de�ZdS)�)�absolute_import�unicode_literalsN)�defaultdict)�partial)�
import_module)�DistutilsOptionError�DistutilsFileError)�
LegacyVersion�parse)�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�dirnameZfind_config_files�appendZparse_config_files�parse_configuration�command_options�configuration_to_dict)	�filepathZfind_othersrrr
Zcurrent_directoryZdistr�handlers�r�/usr/lib/python3.6/config.py�read_configurations$

rcCsltt�}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_dictZhandlerZ	obj_aliasr"Zoption�getter�valuerrrr=s
rcCs6t|||�}|j�t|j|||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�metarrrrZs
rc@s�eZdZdZdZiZd!dd�Zedd��Zdd	�Z	e
d"dd��Ze
d
d��Ze
dd��Z
e
dd��Zedd��Zedd��Ze
d#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�striprr"�sectionsr#)�selfr"r+rr4r!�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__)r5rrr�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)	r5Zoption_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)r3)�.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)rR�	partitionrr3)rPr&rQ�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\r])�lower)rPr&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)rrrr3)rIrrrr�	<genexpr>sz,ConfigHandler._parse_file.<locals>.<genexpr>rGrHc3s2|]*}�j|�sdrtjj|�r�j|�VqdS)TN)�
_assert_localrrr�
_read_file)rIr)rPrrr`
s)rLrr1�lenrO�join)rPr&Zinclude_directive�specZ	filepathsr)rPr�_parse_file�s


zConfigHandler._parse_filecCs|jtj��std|��dS)Nz#`file:` directive can not access %s)r1rrr)rrrrraszConfigHandler._assert_localc	Cs"tj|dd��
}|j�SQRXdS)Nzutf-8)�encoding)�io�open�read)r�frrrrbszConfigHandler._read_filecCs�d}|j|�s|S|j|d�j�jd�}|j�}dj|�}|p@d}tj�}|r�|d|kr�||d}|jdd�}	t	|	�dkr�tj
jtj�|	d�}|	d}q�|}nd|kr�tj
jtj�|d�}tj
jd|�zt
|�}
t|
|�}Wdtj
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:r.r/r8r�/�N)r1r2r3rO�poprdrr�rsplitrcr�sys�insertrr$)rPr&r*Zattr_directiveZ
attrs_pathZ	attr_nameZmodule_name�parent_pathZcustom_path�parts�modulerrr�_parse_attrs0


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
Qs
z1ConfigHandler._get_parser_compound.<locals>.parser)rPrxr
r)rxr�_get_parser_compoundHs	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)rYrrr�<lambda>fsz6ConfigHandler._parse_section_to_dict.<locals>.<lambda>)r0)rPr7Z
values_parserr&rW�_rYrrr�_parse_section_to_dict[s

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)r0r@)r5r7�namer{r&rrr�
parse_sectionks
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.

        r.z_%szparse_section%sr/�__Nz0Unsupported distribution option section: [%s.%s])r4r0r$r2rr!)r5r6r7Zmethod_postfixZsection_parser_methodrrrr
wszConfigHandler.parse)F)rG)N)N)r;�
__module__�__qualname__�__doc__r!r>r8�propertyr<rF�classmethodrRrZr_rf�staticmethodrarbruryr|r~r
rrrrr-ts(
&
 ,r-csHeZdZdZddddd�ZdZd�fd	d
�	Zedd��Zd
d�Z	�Z
S)r(r)Zurl�description�classifiers�	platforms)Z	home_pageZsummaryZ
classifier�platformFNcstt|�j|||�||_dS)N)�superr(r8r*)r5r"r+rr*)r:rrr8�szConfigMetadataHandler.__init__cCs8|j}|j}|j}||||||j||�||||j|d�S)z.Metadata item name to parser function mapping.)r��keywordsZprovidesZrequiresZ	obsoletesr��licenser�Zlong_description�versionZproject_urls)rRrfrZry�_parse_version)r5�
parse_listZ
parse_file�
parse_dictrrrr<�s
zConfigMetadataHandler.parserscCs�|j|�}||kr<|j�}tt|�t�r8td||f��|S|j||j�}t|�rX|�}t|t	�s�t
|d�r~djtt
|��}nd|}|S)zSParses `version` option value.

        :param value:
        :rtype: str

        z7Version loaded from %s does not comply with PEP 440: %s�__iter__r/z%s)rfr3rLr
r	rrur*�callabler�hasattrrd�map�str)r5r&r�rrrr��s


z$ConfigMetadataHandler._parse_version)FN)r;r�r�r!r>Zstrict_moder8r�r<r��
__classcell__rr)r:rr(�sr(c@sTeZdZdZedd��Zdd�Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�ZdS)r'r+cCsL|j}t|jdd�}|j}|j}|||||||||||||||j|j|d�S)z.Metadata item name to parser function mapping.�;)rQ)Zzip_safeZuse_2to3Zinclude_package_datar*Zuse_2to3_fixersZuse_2to3_exclude_fixersZconvert_2to3_doctests�scriptsZeager_resourcesZdependency_linksZnamespace_packagesZinstall_requiresZsetup_requiresZ
tests_requireZpackages�entry_pointsZ
py_modules)rRrr_rZ�_parse_packagesrf)r5r�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)r1rR�parse_section_packages__findr4r?Z
setuptoolsr�)r5r&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)rI�k�v)�
valid_keysrrrKszEConfigOptionsHandler.parse_section_packages__find.<locals>.<listcomp>Nr)r|rRr r0r?)r5r7Z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|rR)r5r7rvrrr�parse_section_entry_points%sz/ConfigOptionsHandler.parse_section_entry_pointscCs.|j||j�}|jd�}|r*||d<|d=|S)N�*r.)r|rRr?)r5r7rv�rootrrr�_parse_package_data-s
z(ConfigOptionsHandler._parse_package_datacCs|j|�|d<dS)z`Parses `package_data` configuration file section.

        :param dict section_options:
        Zpackage_dataN)r�)r5r7rrr�parse_section_package_data7sz/ConfigOptionsHandler.parse_section_package_datacCs|j|�|d<dS)zhParses `exclude_package_data` configuration file section.

        :param dict section_options:
        Zexclude_package_dataN)r�)r5r7rrr�"parse_section_exclude_package_data>sz7ConfigOptionsHandler.parse_section_exclude_package_datacCs"t|jdd�}|j||�|d<dS)zbParses `extras_require` configuration file section.

        :param dict section_options:
        r�)rQZextras_requireN)rrRr|)r5r7r�rrr�parse_section_extras_requireFsz1ConfigOptionsHandler.parse_section_extras_requireN)
r;r�r�r!r�r<r�r�r�r�r�r�r�rrrrr'�s
r')FF)F)Z
__future__rrrhrrp�collectionsr�	functoolsr�	importlibrZdistutils.errorsrrZ#setuptools.extern.packaging.versionr	r
Zsetuptools.extern.sixrrrr�objectr-r(r'rrrr�<module>s"
.
M

Hacked By AnonymousFox1.0, Coded By AnonymousFox