ok

Mini Shell

Direktori : /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

�t^�?�@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�dirnameZfind_config_files�appendZparse_config_files�parse_configuration�command_options�configuration_to_dict)	�filepathZfind_othersr
r
rZcurrent_directoryZdistr�handlers�r�
/config.py�read_configuration
s$

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
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)Z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 r*r
r2r�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__)r3rrr�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)	r3Zoption_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)r1)�.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)rP�	partitionrr1)rNr$rO�result�line�key�sep�valrrr�_parse_dict�s
zConfigHandler._parse_dictcCs|j�}|dkS)zQRepresents value as boolean.

        :param value:
        :rtype: bool
        �1�true�yes)rYrZr[)�lower)rNr$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)rrrr1)rGrrrr�	<genexpr>sz,ConfigHandler._parse_file.<locals>.<genexpr>rErFc3s2|]*}�j|�sdrtjj|�r�j|�VqdS)TN)�
_assert_localrrr�
_read_file)rGr)rNrrr^	s)rJr	r/�lenrM�join)rNr$Zinclude_directive�specZ	filepathsr)rNr�_parse_file�s


zConfigHandler._parse_filecCs|jtj��std|��dS)Nz#`file:` directive can not access %s)r/rrr)rrrrr_szConfigHandler._assert_localc	Cs"tj|dd��
}|j�SQRXdS)Nzutf-8)�encoding)�io�open�read)r�frrrr`szConfigHandler._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:r,r-r6rN�)
r/r0r1rM�poprb�sysr�insertrrrr")rNr$Zattr_directiveZ
attrs_pathZ	attr_nameZmodule_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)rNrrr'r)rrr�_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)rWrrr�<lambda>Wsz6ConfigHandler._parse_section_to_dict.<locals>.<lambda>)r.)rNr5Z
values_parserr$rU�_rWrrr�_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)r.r>)r3r5�namerur$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.

        r,z_%szparse_section%sr-�__Nz0Unsupported distribution option section: [%s.%s])r2r.r"r0rr)r3r4r5Zmethod_postfixZsection_parser_methodrrrr'hszConfigHandler.parse)F)rE)N)r9�
__module__�__qualname__�__doc__rr<r6�propertyr:rD�classmethodrPrXr]rd�staticmethodr_r`rorsrvrxr'rrrrr+ss&
&
 r+c@s6eZdZdZddddd�ZdZedd	��Zd
d�ZdS)
r%r&Zurl�description�classifiers�	platforms)Z	home_pageZsummaryZ
classifier�platformFc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)rPrdrXrs�_parse_version)r3�
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__r-z%s)ro�callablerJr	�hasattrrb�map�str)r3r$r�rrrr��s


z$ConfigMetadataHandler._parse_versionN)	r9rzr{rr<Zstrict_moder}r:r�rrrrr%�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.�;)rO)Zzip_safeZuse_2to3Zinclude_package_dataZpackage_dirZuse_2to3_fixersZuse_2to3_exclude_fixersZconvert_2to3_doctests�scriptsZeager_resourcesZdependency_linksZnamespace_packagesZinstall_requiresZsetup_requiresZ
tests_requireZpackages�entry_pointsZ
py_modules)rPrr]rX�_parse_packagesrd)r3r�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)r/rP�parse_section_packages__findr2r=Z
setuptoolsr�)r3r$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�includeZexcludecs$g|]\}}|�kr|r||f�qSrr)rG�k�v)�
valid_keysrrrI�szEConfigOptionsHandler.parse_section_packages__find.<locals>.<listcomp>Nr)rvrPrr.r=)r3r5Z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)rvrP)r3r5rprrr�parse_section_entry_pointssz/ConfigOptionsHandler.parse_section_entry_pointscCs.|j||j�}|jd�}|r*||d<|d=|S)N�*r,)rvrPr=)r3r5rp�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�)r3r5rrr�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�)r3r5rrr�"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�)rOZextras_requireN)rrPrv)r3r5r�rrr�parse_section_extras_require%sz1ConfigOptionsHandler.parse_section_extras_requireN)
r9rzr{rr}r:r�r�r�r�r�r�r�rrrrr(�s
r()FF)F)Z
__future__rrrfrrl�collectionsr�	functoolsr�	importlibrZdistutils.errorsrrZsetuptools.extern.sixr	rrr�objectr+r%r(rrrr�<module>s 
.
;

Zerion Mini Shell 1.0