Edit File: config.cpython-36.pyc
3 U('dVF������������������@���s����d�dl�mZmZ�d�dlZd�dlZd�dlZd�dlmZ�d�dlm Z �d�dl mZ�d�dlm Z mZ�d�dlmZmZ�d�dlmZ�dd d�Zdd ��Zddd�ZG�dd��de�ZG�dd��de�ZG�dd��de�ZdS�)�����)�absolute_import�unicode_literalsN)�defaultdict)�partial)� import_module)�DistutilsOptionError�DistutilsFileError)� LegacyVersion�parse)�string_typesFc������� ������C���s����ddl�m}m}�tjj|��}�tjj|��s4td|����tj��}tj tjj |����zJ|��}|rb|j��ng�}|�|krx|j|���|j ||d��t||j|d�}W�dtj |��X�t|�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���r ���Zcurrent_directoryZdistr����handlers��r����/usr/lib/python3.6/config.py�read_configuration���s$���� r���c�������������C���sl���t�t�}x^|�D�]V}|j}|j}xD|jD�]:}t|d|�d�}|dkrNt||�}n|��}|||�|<�q&W�qW�|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)r���Zconfig_dictZhandlerZ obj_aliasr"���Zoption�getter�valuer���r���r���r���=���s���� r���c�������������C���s6���t�|�||�}|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)Zdistributionr���r����options�metar���r���r���r���Z���s���� r���c���������������@���s����e�Zd�ZdZdZi�Zd!dd�Zedd���Zdd ��Z e d"dd��Ze d d���Ze dd���Z e dd���Zedd���Zedd���Ze d#dd��Ze dd���Ze d$dd��Zdd��Zdd ��ZdS�)%� ConfigHandlerz1Handles metadata supplied in configuration files.NFc�������������C���sb���i�}|�j�}x:|j��D�].\}}|j|�s(q|j|d�jd�}|||<�qW�||�_||�_||�_g�|�_d�S�)N���.) r!����items� startswith�replace�stripr���r"����sectionsr#���)�selfr"���r+���r���r4���r!����section_name�section_optionsr���r���r����__init__����s���� zConfigHandler.__init__c�������������C���s���t�d|�jj���dS�)z.Metadata item name to parser function mapping.z!%s must provide .parsers propertyN)�NotImplementedError� __class__�__name__)r5���r���r���r����parsers����s����zConfigHandler.parsersc������� ������C���s����t���}|�j}|�jj||�}t|||�}||kr6t|��|r>d�S�d}|�jj|�}|r�y||�}W�n �tk r~���d}|�jsz��Y�nX�|r�d�S�t|d|�d��}|d�kr�t |||��n||��|�j j|��d�S�)NFTzset_%s)�tupler"����aliases�getr$����KeyErrorr<���� Exceptionr����setattrr#���r���) r5���Zoption_namer&����unknownr"���Z current_valueZskip_option�parser�setterr���r���r����__setitem__����s0����zConfigHandler.__setitem__�,c�������������C���s8���t�|t�r|S�d|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 � c�������������S���s���g�|�]}|j���r|j����qS�r���)r3���)�.0�chunkr���r���r���� <listcomp>����s����z-ConfigHandler._parse_list.<locals>.<listcomp>)� isinstance�list� splitlines�split)�clsr&���� separatorr���r���r����_parse_list����s���� zConfigHandler._parse_listc�������������C���sT���d}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���� partitionr���r3���)rP���r&���rQ����result�line�key�sep�valr���r���r����_parse_dict����s���� zConfigHandler._parse_dictc�������������C���s���|j���}|dkS�)zQRepresents value as boolean. :param value: :rtype: bool �1�true�yes)r[���r\���r]���)�lower)rP���r&���r���r���r����_parse_bool����s����zConfigHandler._parse_boolc����������������s\���d}t�|t�s|S�|j|�s |S�|t|�d��}dd��|jd�D��}dj��fdd�|D���S�)ai��Represents 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:Nc�������������s���s���|�]}t�jj|j���V��qd�S�)N)r���r���r���r3���)rI���r���r���r���r���� <genexpr>��s����z,ConfigHandler._parse_file.<locals>.<genexpr>rG���rH���c�������������3���s2���|�]*}��j�|�sd�rtjj|�r��j|�V��qdS�)TN)� _assert_localr���r���r���� _read_file)rI���r���)rP���r���r���r`��� ��s���)rL���r���r1����lenrO����join)rP���r&���Zinclude_directive�specZ filepathsr���)rP���r����_parse_file����s���� zConfigHandler._parse_filec�������������C���s���|�j�tj���std|����d�S�)Nz#`file:` directive can not access %s)r1���r���r���r���)r���r���r���r���ra�����s����zConfigHandler._assert_localc���������� ���C���s"���t�j|�dd�� }|j��S�Q�R�X�d�S�)Nzutf-8)�encoding)�io�open�read)r����fr���r���r���rb�����s����zConfigHandler._read_filec�������������C���s����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 jd|��zt |�} t| |�}W�dtj 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/���r8���r����/����N)r1���r2���r3���rO����poprd���r���r����rsplitrc���r����sys�insertr���r$���)rP���r&���r*���Zattr_directiveZ attrs_pathZ attr_nameZmodule_name�parent_pathZcustom_path�parts�moduler���r���r����_parse_attr��s0���� zConfigHandler._parse_attrc����������������s�����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 c����������������s���|�}x��D�]}||�}q W�|S�)Nr���)r&����parsed�method)� parse_methodsr���r���r ���Q��s���� z1ConfigHandler._get_parser_compound.<locals>.parser���)rP���rx���r ���r���)rx���r����_get_parser_compoundH��s���� z"ConfigHandler._get_parser_compoundc�������������C���s:���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 c�������������S���s���|�S�)Nr���)rY���r���r���r����<lambda>f��s����z6ConfigHandler._parse_section_to_dict.<locals>.<lambda>)r0���)rP���r7���Z values_parserr&���rW����_rY���r���r���r����_parse_section_to_dict[��s ���� z$ConfigHandler._parse_section_to_dictc�������������C���s@���x:|j���D�].\}\}}y||�|<�W�q �tk r6���Y�q X�q W�dS�)zQParses configuration file section. :param dict section_options: N)r0���r@���)r5���r7����namer{���r&���r���r���r���� parse_sectionk��s ����zConfigHandler.parse_sectionc�������������C���sf���x`|�j�j��D�]R\}}d}|r$d|�}t|�d|�jdd�d�}|dkrVtd|�j|f���||��qW�dS�)zTParses configuration file items from one or more related sections. r.���z_%szparse_section%sr/����__Nz0Unsupported distribution option section: [%s.%s])r4���r0���r$���r2���r���r!���)r5���r6���r7���Zmethod_postfixZsection_parser_methodr���r���r���r ���w��s����zConfigHandler.parse)F)rG���)N)N)r;���� __module__�__qualname__�__doc__r!���r>���r8����propertyr<���rF����classmethodrR���rZ���r_���rf����staticmethodra���rb���ru���ry���r|���r~���r ���r���r���r���r���r-���t���s(��� & ,r-���c�������������������sH���e�Zd�ZdZddddd�ZdZd��fd d � Zedd���Zd d��Z ���Z S�)r(���r)���Zurl�description�classifiers� platforms)Z home_pageZsummaryZ classifier�platformFNc����������������s���t�t|��j|||��||�_d�S�)N)�superr(���r8���r*���)r5���r"���r+���r���r*���)r:���r���r���r8������s����zConfigMetadataHandler.__init__c�������������C���s8���|�j�}|�j}|�j}||||||�j||�||||�j|d�S�)z.Metadata item name to parser function mapping.)r�����keywordsZprovidesZrequiresZ obsoletesr�����licenser����Zlong_description�versionZproject_urls)rR���rf���rZ���ry����_parse_version)r5���� parse_listZ parse_file� parse_dictr���r���r���r<������s���� zConfigMetadataHandler.parsersc�������������C���s����|�j�|�}||kr<|j��}tt|�t�r8td||f���|S�|�j||�j�}t|�rX|��}t|t �s�t |d�r~djtt |��}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)rf���r3���rL���r ���r ���r���ru���r*����callabler����hasattrrd����map�str)r5���r&���r����r���r���r���r�������s���� z$ConfigMetadataHandler._parse_version)FN)r;���r����r����r!���r>���Zstrict_moder8���r����r<���r����� __classcell__r���r���)r:���r���r(������s����r(���c���������������@���sT���e�Zd�ZdZedd���Zdd��Zdd��Zdd ��Zd d��Z dd ��Z dd��Zdd��ZdS�)r'���r+���c�������������C���sL���|�j�}t|�j�dd�}|�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)rR���r���r_���rZ����_parse_packagesrf���)r5���r����Zparse_list_semicolonZ parse_boolr����r���r���r���r<������s*����zConfigOptionsHandler.parsersc�������������C���sB���d}|j�|�s|�j|�S�|�j|�jjdi���}ddlm}�|f�|�S�)zTParses `packages` option value. :param value: :rtype: list zfind:z packages.findr���)� find_packages)r1���rR����parse_section_packages__findr4���r?���Z setuptoolsr����)r5���r&���Zfind_directive�find_kwargsr����r���r���r���r�������s���� z$ConfigOptionsHandler._parse_packagesc����������������sT���|�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�excludec����������������s$���g�|�]\}}|��kr|r||f�qS�r���r���)rI����k�v)� valid_keysr���r���rK�����s����zEConfigOptionsHandler.parse_section_packages__find.<locals>.<listcomp>Nr���)r|���rR���r ���r0���r?���)r5���r7���Zsection_datar����r����r���)r����r���r������s���� z1ConfigOptionsHandler.parse_section_packages__findc�������������C���s���|�j�||�j�}||�d<�dS�)z`Parses `entry_points` configuration file section. :param dict section_options: r����N)r|���rR���)r5���r7���rv���r���r���r����parse_section_entry_points%��s����z/ConfigOptionsHandler.parse_section_entry_pointsc�������������C���s.���|�j�||�j�}|jd�}|r*||d<�|d=�|S�)N�*r.���)r|���rR���r?���)r5���r7���rv����rootr���r���r����_parse_package_data-��s���� z(ConfigOptionsHandler._parse_package_datac�������������C���s���|�j�|�|�d<�dS�)z`Parses `package_data` configuration file section. :param dict section_options: Zpackage_dataN)r����)r5���r7���r���r���r����parse_section_package_data7��s����z/ConfigOptionsHandler.parse_section_package_datac�������������C���s���|�j�|�|�d<�dS�)zhParses `exclude_package_data` configuration file section. :param dict section_options: Zexclude_package_dataN)r����)r5���r7���r���r���r����"parse_section_exclude_package_data>��s����z7ConfigOptionsHandler.parse_section_exclude_package_datac�������������C���s"���t�|�jdd�}|�j||�|�d<�dS�)zbParses `extras_require` configuration file section. :param dict section_options: r����)rQ���Zextras_requireN)r���rR���r|���)r5���r7���r����r���r���r����parse_section_extras_requireF��s����z1ConfigOptionsHandler.parse_section_extras_requireN) r;���r����r����r!���r����r<���r����r����r����r����r����r����r����r���r���r���r���r'������s��� r'���)FF)F)Z __future__r���r���rh���r���rp����collectionsr���� functoolsr���� importlibr���Zdistutils.errorsr���r���Z#setuptools.extern.packaging.versionr ���r ���Zsetuptools.extern.sixr���r���r���r����objectr-���r(���r'���r���r���r���r����<module>���s"��� . ��M