Viewing File: /opt/alt/python38/lib/python3.8/site-packages/pbr/__pycache__/util.cpython-38.opt-1.pyc

U

•V.aã @sÌdZzddlZWnek
r$YnXddlZddlZddlZddlZddlZddlm	Z	ddl
ZddlmZddl
mZmZmZddlmZddlmZddlmZzddlZWnek
rÎddlZYnXdd	lmZddlZe d
¡Zdddddddd
ddddddddddddddddddddddddœZdZdZ d Z!d!d"„Z"d@d$d%„Z#d&d'„Z$d(d)„Z%d*d+„Z&d,d-„Z'd.d/„Z(d0d1„Z)d2d3„Z*d4d5„Z+d6d7„Z,d8d9„Z-d:d;„Z.Gd<d=„d=e	ƒZ/Gd>d?„d?e0ƒZ1dS)Aa¹The code in this module is mostly copy/pasted out of the distutils2 source
code, as recommended by Tarek Ziade.  As such, it may be subject to some change
as distutils2 development continues, and will have to be kept up to date.

I didn't want to use it directly from distutils2 itself, since I do not want it
to be an installation dependency for our packages yet--it is still too unstable
(the latest version on PyPI doesn't even install).
éN)Údefaultdict)Úlog)ÚDistutilsOptionErrorÚDistutilsModuleErrorÚDistutilsFileError)Úmanifest_maker)ÚDistribution)Ú	Extension)Úextra_filesz\s*(.*?)\s*\((.*)\)\s*$)Úmetadata)rZ	home_page)rZsummary)rÚdescription)rZ
classifier)rÚplatform)rZ
requires_dist)rZsetup_requires_dist)rZ
provides_dist)rZobsoletes_dist)ÚfilesÚ
packages_root)r)rÚmodules)ÚglobalZcommands)Úbackwards_compatÚuse_2to3)rÚzip_safe)rÚ
tests_require)r)ÚnameÚversionZauthorZauthor_emailZ
maintainerZmaintainer_emailZurlrÚkeywordsÚlong_descriptionzdownload-urlÚclassifiersÚ	platformsÚlicenseÚinstall_requiresÚsetup_requiresÚprovidesÚ	obsoletesÚpackage_dirÚpackagesÚpackage_dataÚnamespace_packagesÚ
data_filesÚscriptsÚ
py_modulesÚcmdclassrrrÚdependency_linksÚinclude_package_data)rrrrr r$r"r#r%r&r'r)rrr()rrr*)rc	CsÒ| d¡}t|ƒd}|d|…}|d}|dkrztd |¡|gd}WqWq*tk
rŒ|dkrh‚|d8}|d|…}||}d}Yq*Xq*||d…D]0}zt||ƒ}Wqœtk
rÊt|ƒ‚YqœXqœ|S)zResolve a name like ``module.object`` to an object and return it.

    Raise ImportError if the module or name is not found.
    Ú.éNéÿÿÿÿr)ÚfromlistÚ)ÚsplitÚlenÚ
__import__ÚjoinÚImportErrorÚgetattrÚAttributeError)rÚpartsZcursorÚmodule_nameZ	attr_nameZretÚpart©r:ú/util.pyÚresolve_namežs*
r<ú	setup.cfgc
	CsÂt ¡}tj |¡s(tdtj |¡ƒ‚| |¡i}| ¡D]}t	| 
|¡ƒ||<q>t|ddƒ}t|ddƒ}|rŒtj |¡}tj 
d|¡z|r&dd„t|ƒDƒ}|D]x}t|ƒ}z||ƒWq¬tk
rât d	¡Yq¬t ¡d
}t d||f¡t t ¡¡t d
¡Yq¬Xq¬tj |¡t|ƒ}	d|	d
<d|	d<t|ƒt|ƒ}
|
rh|
|	d<t|ƒ}|r~||	d<t|	ƒt|ddƒ}|r¦t  !t|ƒ¡W5|r¼tj d¡X|	S)aP Distutils2 to distutils1 compatibility util.

        This method uses an existing setup.cfg to generate a dictionary of
        keywords that can be used by distutils.core.setup(kwargs**).

        :param file:
            The setup.cfg path.
        :raises DistutilsFileError:
            When the setup.cfg file is not found.

    zfile '%s' does not existrÚsetup_hooksrrrcSsg|]}|dkr|‘qS)zpbr.hooks.setup_hookr:)Ú.0Úhookr:r:r;Ú
<listcomp>âsÿzcfg_to_args.<locals>.<listcomp>z)setup hook %s terminated the installationr,z#setup hook %s raised exception: %s
Tr*FrÚext_modulesÚentry_pointsr
)"ÚconfigparserZSafeConfigParserÚosÚpathÚexistsrÚabspathÚreadZsectionsÚdictÚitemsÚhas_get_optionÚsysÚinsertÚpopÚsplit_multiliner<Ú
SystemExitrÚerrorÚexc_infoÚ	tracebackÚ
format_excÚexitÚpbrÚhooksZ
setup_hookÚsetup_cfg_to_setup_kwargsÚregister_custom_compilersÚget_extension_modulesÚget_entry_pointsÚ
wrap_commandsr
Zset_extra_files)
rFÚparserÚconfigÚsectionr>r!r@Zhook_fnÚeÚkwargsrBrCZfiles_extra_filesr:r:r;Úcfg_to_args¾sd
ÿ
ÿÿrcc"
CsŽi}i}tD]œ}tt|ƒdkr0t|\}}n tt|ƒdkrPt|d}|}t|||ƒ}|sÂ|dkrt||dƒ}|rÂt|ƒ}d}|D]0}t|ƒ}	z||	 ¡ ¡d7}W5|	 ¡Xqˆ|}nq|tkrÒt	|ƒ}|t
krät|ƒ}n"|tkr| ¡dkrd	}nd
}|r¢|dkr$dd
„|Dƒ}|dkr„g}
d}|D]<}t
 ||¡}
|
 d¡ ¡}|
 d¡ ¡}|
 ||f¡q:|
|d<n|dkršd|i}n|dkrbi}d	}d}|D]”}d|kr| dd¡\}}| ¡| ¡}}||kr||}| | ¡¡n| ¡}|| ¡<n&|r0td|ƒ‚n| | ¡ ¡¡d
}q´|dkr\| ¡}|}n@|dkr¢i}tƒ}|D]"}t|ƒ}||ƒ}||| ¡<qz|}|||<qd|kr$d}|d}|D]\}g}t||ƒ}|D]8}t
 ||¡}
|
 d¡ ¡}|
 d¡}| ||f¡qÞ|||<qÆi}|D]D} || D]4\}}|rTd| |f}!n| }!| |!g¡ |¡q8q,| dg¡|d<||d<|S)zqProcesses the setup.cfg options and converts them to arguments accepted
    by setuptools' setup() function.
    ér,rrÚdescription_filer/z

)ÚtrueÚtÚ1ZyesÚyTF)rrcSsg|]}t d|¡‘qS)z\1\2)Ú_VERSION_SPEC_REÚsub)r?Zpredr:r:r;rAKsÿz-setup_cfg_to_setup_kwargs.<locals>.<listcomp>rz6(?P<package>[^;]*);?(?P<env_marker>[^#]*?)(?:\s*#.*)?$ÚpackageÚ
env_markerr!)r#r%Nú=z1malformed package_data first line %r (misses "=")r%r(Úextrasz6(?P<package>[^:]*):?(?P<env_marker>[^#]*?)(?:\s*#.*)?$z%s:(%s)Úextras_require)ÚD1_D2_SETUP_ARGSr1rLrPÚopenÚcloserIÚstripÚ
CSV_FIELDSÚ	split_csvÚMULTI_FIELDSÚBOOL_FIELDSÚlowerÚreÚmatchÚgroupÚappendr0ÚextendrrKrr<Úget_command_nameÚ
setdefaultrO)"r_rbZall_requirementsÚargr`ÚoptionZin_cfg_valueÚvalueÚfilenamererZrequirement_patternZrequirementÚmZrequirement_packagermr%Ú	firstlineÚprevÚlineÚkeyr(ÚdistZcls_nameÚclsÚcmdroZextraZextra_requirementsZrequirementsZextras_valuerpZ	req_groupZ
extras_keyr:r:r;rYsÌ
ÿ


ÿ




ÿÿ





rYcCs’t|ddƒ}|rŽt|ƒ}|D]p}t|ƒ}t|dƒr:|j}n|j}t|dƒrR|j}nd|}|j}tj	j
}||j|f||<tj|tjd|<qdS)z²Handle custom compilers; this has no real equivalent in distutils, where
    additional compilers could only be added programmatically, so we have to
    hack it in somehow.
    rÚ	compilersrrzcustom compiler %sz
distutils.N)
rLrPr<ÚhasattrrÚ__name__rÚ
__module__Ú	distutilsZ	ccompilerZcompiler_classrMr)r_rZcompilerrZdescr8Zccr:r:r;rZ°s

rZc
Cs(d}g}|D]}d|kr(| dd¡}n| dd¡}dd„|Dƒ}t|ƒdkr|dd	kri}|D]Œ}t|||ƒ}|sxqbt|ƒ}|d
kræg}|D]P}	|	 dd¡}	t|	ƒdkr¾|	d ¡df}	n|	d ¡|	d ¡f}	| |	¡q|}|||<qb|rd|kr
|d|d<| t| d¡f|Ž¡q|S)
zHandle extension modules)
ZsourcesZinclude_dirsÚ
define_macrosZundef_macrosZlibrary_dirsZ	librariesZruntime_library_dirsZ
extra_objectsZextra_compile_argsZextra_link_argsZexport_symbolsZ	swig_optsZdependsú:r,rncSsg|]}| ¡‘qSr:©rt)r?Úlr:r:r;rAêsz)get_extension_modules.<locals>.<listcomp>rdrÚ	extensionr’Nr)r0r1rLrPrtr}r	rO)
r_ZEXTENSION_FIELDSrBr`ÚlabelsZext_argsZfieldrƒZmacrosZmacror:r:r;r[Òs>


ÿr[cCs&d|kriStdd„|d ¡DƒƒS)aProcess the [entry_points] section of setup.cfg to handle setuptools
    entry points.  This is, of course, not a standard feature of
    distutils2/packaging, but as there is not currently a standard alternative
    in packaging, we provide support for them.
    rCcss|]\}}|t|ƒfVqdS©N)rP)r?r‚rƒr:r:r;Ú	<genexpr>sÿz#get_entry_points.<locals>.<genexpr>)rJrK)r_r:r:r;r\s

ÿr\cCsÎtƒ}| ¡| ¡D]²\}}i}| |¡ ¡D]H\}}|d}| d¡sT| d¡r0| dd¡\}}| |i¡}	||	|<q0|s€qd|kr¢||dkr¢|d|}
n
| |¡}
t	||
|ƒ}|| di¡|<qdS)Nr,z	pre_hook.z
post_hook.r+r()
rZparse_config_filesZget_command_listZget_option_dictrKÚ
startswithr0r€Zget_command_classÚwrap_command)rbrŠrŒÚ_rXÚoptÚvalZ	hook_typeÚaliasZ	hook_dictr(Znew_cmdclassr:r:r;r]s"

r]c	Cs2|fdd„}t||tf|t| d¡| d¡dœƒS)NcSs"| d¡| |¡| d¡dS)NÚpre_hookÚ	post_hook)Úrun_command_hooksÚrun)Úselfr(r:r:r;r£2s

zwrap_command.<locals>.runr r¡)r£r¢r r¡)ÚtypeÚobjectr¢Úget)rŒr(rXr£r:r:r;r›1s
þÿr›c	Cs|dkrtd|ƒ‚t||dƒ}|dkr,dS| ¡D]Ì}t|tƒr‚zt|ƒ}Wq†tk
r~t ¡d}t	d||fƒ‚Yq†Xn|}t
|dƒsœtd|ƒ‚t 
d||| ¡¡z||ƒWq4t ¡d}t d	||f¡t t ¡¡t d¡Yq4Xq4dS)
z˜Run hooks registered for that command and phase.

    *cmd_obj* is a finalized command object; *hook_kind* is either
    'pre_hook' or 'post_hook'.
    )r r¡zinvalid hook kind: %rNr,zcannot find hook %s: %sÚ__call__zhook %r is not callablezrunning %s %s for command %szhook %s raised exception: %s
)Ú
ValueErrorr5ÚvaluesÚ
isinstanceÚstrr<r4rMrSrrŽrrÚinforrRrTrUrV)Zcmd_objZ	hook_kindrXr@Zhook_objÚerrrar:r:r;r¢=s:
ÿ
ÿr¢cCsX||kr |||kr |||S||krP| dd¡||krP||| dd¡SdSdS)Nrœú-F©Úreplace)r_r`r‚r:r:r;rLfs
rLcCs"dd„dd„| d¡DƒDƒ}|S)z3Special behaviour when we have a multi line optionscSsg|]}|r|‘qSr:r:©r?Zelementr:r:r;rArsþz#split_multiline.<locals>.<listcomp>css|]}| ¡VqdSr˜r”)r?rˆr:r:r;r™ssz"split_multiline.<locals>.<genexpr>Ú
©r0©rƒr:r:r;rPosÿrPcCs"dd„dd„| d¡DƒDƒ}|S)z8Special behaviour when we have a comma separated optionscSsg|]}|r|‘qSr:r:r²r:r:r;rA{sþzsplit_csv.<locals>.<listcomp>css|]}| ¡VqdSr˜r”)r?Úchunkr:r:r;r™|szsplit_csv.<locals>.<genexpr>ú,r´rµr:r:r;rvxsÿrvcs‡fdd„}|S)z[A function decorator to monkey-patch a method of the same name on the
    given class.
    cs:tˆ|jdƒ}|r6t|dƒs6t|d|ƒtˆ|j|ƒ|S)NZ_orig)r5rrŽÚsetattr)ÚfuncZorig©r‹r:r;Úwrapper†s
z#monkeypatch_method.<locals>.wrapperr:)r‹r»r:rºr;Úmonkeypatch_methodsr¼cs"eZdZdZd‡fdd„	Z‡ZS)ÚDefaultGetDictzXLike defaultdict, but the get() method also sets and returns the default
    value.
    Ncs"|dkr| ¡}tt|ƒ ||¡Sr˜)Údefault_factoryÚsuperr½r€)r¤r‰Údefault©Ú	__class__r:r;r§–szDefaultGetDict.get)N)rrÚ__qualname__Ú__doc__r§Ú
__classcell__r:r:rÁr;r½‘sr½cs(eZdZdZdd„Z‡fdd„Z‡ZS)Ú
IgnoreDictz²A dictionary that ignores any insertions in which the key is a string
    matching any string in `ignore`.  The ignore list can also contain wildcard
    patterns using '*'.
    cCs$t dd dd„|Dƒ¡¡|_dS)Nz(%s)ú|cSsg|]}| dd¡‘qS)Ú*z.*r°)r?Zpatr:r:r;rA¤sÿz'IgnoreDict.__init__.<locals>.<listcomp>)rzÚcompiler3Ú_IgnoreDict__ignore)r¤Úignorer:r:r;Ú__init__¢s

ÿÿzIgnoreDict.__init__cs&|j |¡rdStt|ƒ ||¡dSr˜)rÊr{r¿rÆÚ__setitem__)r¤r‰ržrÁr:r;rͧszIgnoreDict.__setitem__)rrrÃrÄrÌrÍrÅr:r:rÁr;rÆœsrÆ)r=)2rÄZmultiprocessingr4ZloggingrErzrMrTÚcollectionsrZdistutils.ccompilerr‘rZdistutils.errorsrrrZsetuptools.command.egg_inforZsetuptools.distrZsetuptools.extensionr	ZConfigParserrDrWr
Z	pbr.hooksrÉrjrqrwrxrur<rcrYrZr[r\r]r›r¢rLrPrvr¼r½rJrÆr:r:r:r;Ú<module>.s”
Ý' 
V"5)			
Back to Directory File Manager