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



V.aN@sdZyddlZWnek
r*YnXddlZddlZddlZddlZddlZddlm	Z	ddl
ZddlmZddl
mZmZmZddlmZddlmZddlmZyddlZWnek
rddlZYnXdd	lmZddlZejd
ZddXd
dYddZdd[dd\dd]dd^dd_dd`ddaddbddcdddddeddfd dgd"dhd$did&djd)dkd*dld+dmd,dnd-dod.dpd0dqd3drd5dsd6dtd7dud8dviZdwZdxZ dyZ!d9d:Z"d;d<d=Z#d>d?Z$d@dAZ%dBdCZ&dDdEZ'dFdGZ(dHdIZ)dJdKZ*dLdMZ+dNdOZ,dPdQZ-dRdSZ.GdTdUdUe	Z/GdVdWdWe0Z1dS)zaThe 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)DistutilsOptionErrorDistutilsModuleErrorDistutilsFileError)manifest_maker)Distribution)	Extension)extra_filesz\s*(.*?)\s*\((.*)\)\s*$namemetadataversionZauthorZauthor_emailZ
maintainerZmaintainer_emailZurl	home_pagedescriptionsummarykeywordslong_descriptionzdownload-urlclassifiers
classifier	platformsplatformlicenseinstall_requires
requires_distsetup_requiressetup_requires_distprovides
provides_dist	obsoletesobsoletes_distpackage_dirfiles
packages_rootpackagespackage_datanamespace_packages
data_filesscripts
py_modulesmodulescmdclassglobalcommandsuse_2to3backwards_compatzip_safe
tests_requiredependency_linksinclude_package_datacCs|jd}t|d}|d|}|d}x|dkry#tdj|d|g}PWq<tk
r|dkr|d8}|d|}||}d}Yq<Xq<WxL||dD]:}yt||}Wqtk
rt|YqXqW|S)zResolve a name like ``module.object`` to an object and return it.

    Raise ImportError if the module or name is not found.
    .Nrfromlist)splitlen
__import__joinImportErrorgetattrAttributeError)rpartsZcursormodule_nameZ	attr_nameZretpartrB/util.pyresolve_names*




rDz	setup.cfgc
CsOtj}tjj|s:tdtjj||j|i}x-|jD]}t	|j
|||<qZWt|dd}t|dd}|rtjj|}tjj
d|ze|rddt|D}x|D]}t|}y||Wqtk
r6tjd	Yqtjd
}tjd||ftjtjtjd
YqXqWtjj|t|}	d|	d
<d|	d<t|t|}
|
r|
|	d<t|}|r||	d<t|	t|dd}|r0tj t|Wd|rJtjj!dX|	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_hooksr!r"rcSs"g|]}|dkr|qS)zpbr.hooks.setup_hookrB).0hookrBrBrC
<listcomp>s	zcfg_to_args.<locals>.<listcomp>z)setup hook %s terminated the installationr4z#setup hook %s raised exception: %s
Tr2Fr/ext_modulesentry_pointsr
N)"configparserZSafeConfigParserospathexistsrabspathreadZsectionsdictitemshas_get_optionsysinsertsplit_multilinerD
SystemExitrerrorexc_info	traceback
format_excexitpbrhooksZ
setup_hooksetup_cfg_to_setup_kwargsregister_custom_compilersget_extension_modulesget_entry_points
wrap_commandsr
Zset_extra_filespop)
rMparserconfigsectionrEr rGZhook_fnekwargsrIrJZfiles_extra_filesrBrBrCcfg_to_argss\


	





rjc"Csi}i}xtD]}tt|dkrBt|\}}n*tt|dkrlt|d}|}t|||}|s|dkrt||d}|rt|}d}xF|D]>}t|}	z||	jjd7}Wd|	jXqW|}nq|tkr't	|}|t
krBt|}n-|tkro|jd!krid}nd}|r|d"krdd|D}|dkrg}
d}x]|D]U}t
j||}
|
jdj}|
jdj}|
j||fqW|
|d<n|dkr4d|i}nh|d#krBi}d}d}x|D]}d|kr|jdd\}}|j|j}}||kr||}|j|jq|j}||j<n2|rtd|n|j|jjd}qYW|dkr9|j}|}nZ|dkri}t}x6|D].}t|}||}|||j<qdW|}|||<qWd|krQd}|d}x|D]}g}t||}xW|D]O}t
j||}
|
jdj}|
jd}|j||fqW|||<qWi}xa|D]Y} xP|| D]D\}}|rd| |f}!n| }!|j|!gj|qoWq^W|jdg|d<||d <|S)$zqProcesses the setup.cfg options and converts them to arguments accepted
    by setuptools' setup() function.
    r4rrdescription_filer6z

Ntruet1yesyTFrr0cSs"g|]}tjd|qS)z\1\2)_VERSION_SPEC_REsub)rFZpredrBrBrCrHKs	z-setup_cfg_to_setup_kwargs.<locals>.<listcomp>z6(?P<package>[^;]*);?(?P<env_marker>[^#]*?)(?:\s*#.*)?$package
env_markerr r$r&=z1malformed package_data first line %r (misses "=")r*extrasz6(?P<package>[^:]*):?(?P<env_marker>[^#]*?)(?:\s*#.*)?$z%s:(%s)extras_require)ztruernrozyesrq)zinstall_requiresr0)r$z
data_files)D1_D2_SETUP_ARGSr9rSrVopenrPstripclose
CSV_FIELDS	split_csvMULTI_FIELDSBOOL_FIELDSlowerrematchgroupappendr8extendrrRrrDget_command_name
setdefaultrd)"rfriZall_requirementsargrgoptionZin_cfg_valuevaluefilenamerlrZrequirement_patternZrequirementmZrequirement_packagerur&	firstlineprevlinekeyr*distZcls_nameclscmdrwextraZextra_requirementsZrequirementsZextras_valuerxZ	req_groupZ
extras_keyrBrBrCr_s
		
			






		






!
r_cCst|dd}|rt|}x|D]}t|}t|drX|j}n	|j}t|dr||j}n
d|}|j}tj	j
}||j|f||<tj|tjd|<q+WdS)zHandle 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+	compilersrrzcustom compiler %sz
distutils.N)
rSrVrDhasattrr__name__r
__module__	distutilsZ	ccompilerZcompiler_classrTr))rfrZcompilerrZdescr@ZccrBrBrCr`s
	
	r`c

Csd}g}x|D]}d|kr:|jdd}n|jdd}dd|D}t|dkr|ddkri}x|D]}t|||}|sqt|}|dkrNg}xx|D]p}	|	jdd}	t|	dkr|	djdf}	n |	dj|	djf}	|j|	qW|}|||<qW|rd|kr||d|d<|jt|jd|qW|S)zHandle extension modulessourcesinclude_dirs
define_macrosundef_macroslibrary_dirs	librariesruntime_library_dirs
extra_objectsextra_compile_argsextra_link_argsexport_symbols	swig_optsdepends:r4rvcSsg|]}|jqSrB)r{)rFlrBrBrCrHs	z)get_extension_modules.<locals>.<listcomp>rkr	extensionNr)
rrrrrrrrrrrrr)r8r9rSrVr{rr	rd)
rfZEXTENSION_FIELDSrIrgZlabelsZext_argsZfieldrZmacrosZmacrorBrBrCrasT
"

 racCs1d|kriStdd|djDS)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.
    rJcss'|]\}}|t|fVqdS)N)rV)rFrrrBrBrC	<genexpr>sz#get_entry_points.<locals>.<genexpr>)rQrR)rfrBrBrCrbsrbcCs)t}|jx|jD]\}}i}x|j|jD]h\}}|d}|jds||jdrH|jdd\}}|j|i}	||	|<qHW|sq d|kr||dkr|d|}
n|j|}
t	||
|}||jdi|<q WdS)Nr4z	pre_hook.z
post_hook.r3r*)
rZparse_config_filesZget_command_listZget_option_dictrR
startswithr8rZget_command_classwrap_command)rirr_r^optvalZ	hook_typealiasZ	hook_dictr*Znew_cmdclassrBrBrCrcs"	
"
rccCsO|dd}t||tfd|dtd|jdd|jdiS)NcSs+|jd|j||jddS)Npre_hook	post_hook)run_command_hooksrun)selfr*rBrBrCr2s

zwrap_command.<locals>.runrrrr)typeobjectrget)rr*r^rrBrBrCr1s
rcCsW|dkrtd|t||d}|dkr>dSx|jD]}t|tryt|}Wqtk
rtjd}t	d||fYqXn|}t
|dstd|tj
d	|||jy||WqKtjd}tjd
||ftjtjtjdYqKXqKWdS)zRun hooks registered for that command and phase.

    *cmd_obj* is a finalized command object; *hook_kind* is either
    'pre_hook' or 'post_hook'.
    rrzinvalid hook kind: %rNr4zcannot find hook %s: %s__call__zhook %r is not callablezrunning %s %s for command %szhook %s raised exception: %s
)zpre_hookz	post_hook)
ValueErrorr=values
isinstancestrrDr<rTrYrrrrinforrXrZr[r\)Zcmd_objZ	hook_kindr^rGZhook_objerrrhrBrBrCr=s2
	rcCsp||kr(|||kr(|||S||krh|jdd||krh|||jddSdSdS)Nr-F)replace)rfrgrrBrBrCrSfs
(rScCs-dddd|jdDD}|S)z3Special behaviour when we have a multi line optionscSsg|]}|r|qSrBrB)rFelementrBrBrCrHrs	z#split_multiline.<locals>.<listcomp>css|]}|jVqdS)N)r{)rFrrBrBrCrssz"split_multiline.<locals>.<genexpr>
)r8)rrBrBrCrVos	 rVcCs-dddd|jdDD}|S)z8Special behaviour when we have a comma separated optionscSsg|]}|r|qSrBrB)rFrrBrBrCrH{s	zsplit_csv.<locals>.<listcomp>css|]}|jVqdS)N)r{)rFchunkrBrBrCr|szsplit_csv.<locals>.<genexpr>,)r8)rrBrBrCr~xs	 r~csfdd}|S)z[A function decorator to monkey-patch a method of the same name on the
    given class.
    csRt|jd}|rNt|drNt|d|t|j||S)NZ_orig)r=rrsetattr)funcZorig)rrBrCwrappers
z#monkeypatch_method.<locals>.wrapperrB)rrrB)rrCmonkeypatch_methodsrcs+eZdZdZdfddZS)DefaultGetDictzXLike defaultdict, but the get() method also sets and returns the default
    value.
    Ncs1|dkr|j}tt|j||S)N)default_factorysuperrr)rrdefault)	__class__rBrCrszDefaultGetDict.get)rr__qualname____doc__rrBrB)rrCrsrcs4eZdZdZddZfddZS)
IgnoreDictzA 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 '*'.
    cCs0tjddjdd|D|_dS)Nz(%s)|cSs"g|]}|jddqS)*z.*)r)rFpatrBrBrCrHs	z'IgnoreDict.__init__.<locals>.<listcomp>)rcompiler;_IgnoreDict__ignore)rignorerBrBrC__init__s	zIgnoreDict.__init__cs3|jj|rdStt|j||dS)N)rrrr__setitem__)rrr)rrBrCrszIgnoreDict.__setitem__)rrrrrrrBrB)rrCrsr)r)r)r)r)r)r)rr)rr)r)rzdescription)r)rr)rzplatform)r)rr)rr)rr)rr)filesz
packages_root)r)r)r)r)r)rzmodules)zglobalzcommands)r.r-)r.zip_safe)r.
tests_require)r.)r.)rrzinstall_requiresrrr%r#zpackage_dataz
data_fileszscriptsr(r1rrzcmdclass)r-rzinclude_package_data)zkeywords)2rmultiprocessingr<loggingrLrrTrZcollectionsrZdistutils.ccompilerrrZdistutils.errorsrrrZsetuptools.command.egg_inforZsetuptools.distrZsetuptools.extensionr	ConfigParserrKr]r
Z	pbr.hooksrrrryrrr}rDrjr_r`rarbrcrrrSrVr~rrrQrrBrBrBrC<module>5s

 V"5)			
Back to Directory File Manager