Viewing File: /opt/alt/python35/lib/python3.5/site-packages/setuptools/__pycache__/config.cpython-35.opt-1.pyc



\?@sddlmZmZddlZddlZddlZddlmZddlm	Z	ddl
mZmZddl
mZddlmZddd	d
ZddZdd
dZGdddeZGdddeZGdddeZdS))absolute_importunicode_literalsN)defaultdict)partial)DistutilsOptionErrorDistutilsFileError)
import_module)string_typesFc	Csddlm}m}tjj|}tjj|sJtd|tj}tj	tjj
|zi|}|r|jng}||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.	filenamesignore_option_errorsN)Zsetuptools.distr
rospathabspathisfilergetcwdchdirdirnameZfind_config_filesappendZparse_config_filesparse_configurationcommand_optionsconfiguration_to_dict)	filepathZfind_othersr
r
rZcurrent_directoryZdistrhandlersr
/config.pyread_configuration
s$
	

rcCstt}x|D]w}|j}|j}x\|jD]Q}t|d|d}|dkrot||}n	|}||||<q5WqW|S)zReturns configuration data gathered by given handlers as a dict.

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

    :rtype: dict
    zget_%sN)rdictsection_prefix
target_objset_optionsgetattr)rZconfig_dicthandlerZ	obj_aliasr Zoptiongettervaluerrrr<s
			rcCsEt|j||}|jt|||}|j||gS)aPerforms 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
    )ConfigMetadataHandlermetadataparseConfigOptionsHandler)Zdistributionrr
metaoptionsrrrrYs

rc@seZdZdZdZiZdddZeddZdd	Z	e
d
ddZe
d
dZe
ddZ
e
ddZeddZeddZe
ddZe
ddZe
dddZddZdd ZdS)!
ConfigHandlerz1Handles metadata supplied in configuration files.NFcCsi}|j}xQ|jD]C\}}|j|s:q|j|djd}|||<qW||_||_||_g|_dS)N.)	ritems
startswithreplacestripr
r sectionsr!)selfr r+r
r3rsection_namesection_optionsrrr__init__s				zConfigHandler.__init__cCstd|jjdS)z.Metadata item name to parser function mapping.z!%s must provide .parsers propertyN)NotImplementedError	__class____name__)r4rrrparsersszConfigHandler.parsersc	Cs
t}|j}|jj||}t|||}||krQt||r[dSd}|jj|}|ry||}Wn$tk
rd}|jsYnX|rdSt|d|d}|dkrt	|||n
|||j
j|dS)NFTzset_%s)tupler aliasesgetr"KeyErrorr;	Exceptionr
setattrr!r)	r4Zoption_namer%unknownr Z
current_valueZskip_optionparsersetterrrr__setitem__s0		
	
zConfigHandler.__setitem__,cCsNt|tr|Sd|kr.|j}n|j|}dd|DS)zRepresents 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|]}|jr|jqSr)r2).0chunkrrr
<listcomp>s	z-ConfigHandler._parse_list.<locals>.<listcomp>)
isinstancelist
splitlinessplit)clsr%	separatorrrr_parse_lists
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)rQ	partitionrr2)rOr%rPresultlinekeysepvalrrr_parse_dicts
zConfigHandler._parse_dictcCs|j}|dkS)zQRepresents value as boolean.

        :param value:
        :rtype: bool
        1trueyes)rZr[r\)lower)rOr%rrr_parse_boolszConfigHandler._parse_boolcs~d}t|ts|S|j|s,|S|t|d}dd|jdD}djfdd|DS)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|jVqdS)N)rrrr2)rHrrrr	<genexpr>sz,ConfigHandler._parse_file.<locals>.<genexpr>rFrGc3sE|];}j|sdrtjj|rj|VqdS)TN)
_assert_localrrr
_read_file)rHr)rOrrr_	s)rKr	r0lenrNjoin)rOr%Zinclude_directivespecZ	filepathsr)rOr_parse_fileszConfigHandler._parse_filecCs)|jtjs%td|dS)Nz#`file:` directive can not access %s)r0rrr)rrrrr`szConfigHandler._assert_localc	Cs-tj|dd}|jSWdQRXdS)Nencodingzutf-8)ioopenread)rfrrrraszConfigHandler._read_filecCsd}|j|s|S|j|djjd}|j}dj|}|p^d}tjjdt	j
zt|}t||}Wdtjddt_X|S)zRepresents value as a module attribute.

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

        :param str value:
        :rtype: str
        zattr:r-r.r7rN)
r0r1r2rNpoprcsysrinsertrrrr")rOr%Zattr_directiveZ
attrs_pathZ	attr_namemodule_namemodulerrr_parse_attrs!zConfigHandler._parse_attrcsfdd}|S)zReturns parser function to represents value as a list.

        Parses a value applying given methods one after another.

        :param parse_methods:
        :rtype: callable
        cs'|}xD]}||}q
W|S)Nr)r%parsedmethod)
parse_methodsrrr(Bs
z1ConfigHandler._get_parser_compound.<locals>.parser)rOrtr(r)rtr_get_parser_compound9s	z"ConfigHandler._get_parser_compoundcCsOi}|pdd}x0|jD]"\}\}}||||<q%W|S)zParses 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)rXrrr<lambda>Wsz6ConfigHandler._parse_section_to_dict.<locals>.<lambda>)r/)rOr6Z
values_parserr%rV_rXrrr_parse_section_to_dictLs

z$ConfigHandler._parse_section_to_dictcCsJxC|jD]5\}\}}y|||<Wq
tk
rAYq
Xq
WdS)zQParses configuration file section.

        :param dict section_options:
        N)r/r?)r4r6namerwr%rrr
parse_section\s

zConfigHandler.parse_sectioncCsx|jjD]s\}}d}|r2d|}t|d|jddd}|dkrytd|j|f||qWdS)zTParses configuration file items from one
        or more related sections.

        r-z_%szparse_section%sr.__Nz0Unsupported distribution option section: [%s.%s])r3r/r"r1rr)r4r5r6Zmethod_postfixZsection_parser_methodrrrr(hs
	zConfigHandler.parse)r:
__module____qualname____doc__rr=r7propertyr;rEclassmethodrQrYr^restaticmethodr`rarqrurxrzr(rrrrr,ss&&
 r,c@sXeZdZdZdddddddd	iZd
ZeddZd
dZdS)r&r'Z	home_pageZurlZsummarydescriptionZ
classifierclassifiersplatform	platformsFcCsa|j}|j}d|d|d|d|d|d|j||d|d|d	|d
|ji
S)z.Metadata item name to parser function mapping.rkeywordsZprovidesZrequiresZ	obsoletesrlicenserZlong_descriptionversion)rQreru_parse_version)r4
parse_listZ
parse_filerrrr;s		zConfigMetadataHandler.parserscCsk|j|}t|r$|}t|tsgt|dr]djtt|}n
d|}|S)zSParses `version` option value.

        :param value:
        :rtype: str

        __iter__r.z%s)rqcallablerKr	hasattrrcmapstr)r4r%rrrrrs	
z$ConfigMetadataHandler._parse_versionN)	r:r|r}rr=Zstrict_moderr;rrrrrr&sr&c@s|eZdZdZeddZddZddZdd	Zd
dZ	dd
Z
ddZddZdS)r)r+c"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.rP;Zzip_safeZuse_2to3Zinclude_package_dataZpackage_dirZuse_2to3_fixersZuse_2to3_exclude_fixersZconvert_2to3_doctestsscriptsZeager_resourcesZdependency_linksZnamespace_packagesZinstall_requiresZsetup_requiresZ
tests_requireZpackagesentry_pointsZ
py_modules)rQrr^rY_parse_packagesre)r4rZparse_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)r0rQparse_section_packages__findr3r>Z
setuptoolsr)r4r%Zfind_directivefind_kwargsrrrrrs
z$ConfigOptionsHandler._parse_packagescsv|j||j}dddgtfdd|jD}|jd}|dk	rr|d|d<|S)zParses `packages.find` configuration file section.

        To be used in conjunction with _parse_packages().

        :param dict section_options:
        whereincludeZexcludecs4g|]*\}}|kr|r||fqSrr)rHkv)
valid_keysrrrJs	zEConfigOptionsHandler.parse_section_packages__find.<locals>.<listcomp>Nr)rxrQrr/r>)r4r6Zsection_datarrr)rrrs"z1ConfigOptionsHandler.parse_section_packages__findcCs#|j||j}||d<dS)z`Parses `entry_points` configuration file section.

        :param dict section_options:
        rN)rxrQ)r4r6rrrrrparse_section_entry_pointssz/ConfigOptionsHandler.parse_section_entry_pointscCs?|j||j}|jd}|r;||d<|d=|S)N*r-)rxrQr>)r4r6rrrootrrr_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)r4r6rrrparse_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)r4r6rrr"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:
        rPrZextras_requireN)rrQrx)r4r6rrrrparse_section_extras_require#sz1ConfigOptionsHandler.parse_section_extras_requireN)
r:r|r}rrr;rrrrrrrrrrrr)s
r))Z
__future__rrrgrrmcollectionsr	functoolsrZdistutils.errorsrrZsetuptools.py26compatrZsetuptools.extern.sixr	rrrobjectr,r&r)rrrr<module>s.9
Back to Directory File Manager