B }e^@sdZddlZddlZejddkZer.efZnddlZefZddl m Z iZ da e ZddZe ed d Zd d Zd dZe eddZGdddZGdddZGdddZddZdS)zThis module implements a post import hook mechanism styled after what is described in PEP-369. Note that it doesn't cope with modules being reloaded. N) synchronizedFcsfdd}|S)NcsJd\}}|d}t|tj|}x|D]}t||}q0W||S)N:.)split __import__sysmodulesgetattr)module module_namefunctionattrscallbackattr)name7/tmp/pip-target-9_2btsuh/lib64/python/wrapt/importer.py import_hook%s   z4_create_import_hook_from_string..import_hookr)rrr)rr_create_import_hook_from_string$s rcCst|trt|}ts*datjdtt |d}|dkrrtj |d}|dk rfgt|<||q|gt|<n*|gkrtj |}||nt| |dS)NTr) isinstance string_typesr_post_import_hooks_initr meta_pathinsertImportHookFinder_post_import_hooksgetr append)hookrhooksr rrrregister_post_import_hook/s       r"csfdd}|S)Ncs8tjtjj}xjD]}t||}qW||S)N)rr r r rr )r rr) entrypointrrrgs    z8_create_import_hook_from_entrypoint..import_hookr)r#rr)r#r#_create_import_hook_from_entrypointfs r$cCsPy ddl}Wntk r dSXx(|j|dD]}t|}t||jq0WdS)Nr)group) pkg_resources ImportErroriter_entry_pointsr$r"r)r%r&r#rrrrdiscover_post_import_hooksos r)cCs>t|dd}t|d}|r:gt|<x|D] }||q*WdS)N__name__)r rr)r rr!r rrrnotify_module_loaded~s    r+c@seZdZddZdS)_ImportHookLoadercCstj|}t||S)N)r r r+)selffullnamer rrr load_modules z_ImportHookLoader.load_moduleN)r* __module__ __qualname__r/rrrrr,sr,c@seZdZddZddZdS)_ImportHookChainedLoadercCs ||_dS)N)loader)r-r3rrr__init__sz!_ImportHookChainedLoader.__init__cCs|j|}t||S)N)r3r/r+)r-r.r rrrr/s z$_ImportHookChainedLoader.load_moduleN)r*r0r1r4r/rrrrr2sr2c@s&eZdZddZeedddZdS)rcCs i|_dS)N) in_progress)r-rrrr4szImportHookFinder.__init__Nc Cs|tkr dS||jkrdSd|j|<zbtr8t|tSyddl}|j|j}Wn$t t fk rv| ||}YnX|rt |SWd|j|=XdS)NTr) rr5PY2rr,importlib.utilutil find_specr3r'AttributeError find_loaderr2)r-r.path importlibr3rrr find_modules"     zImportHookFinder.find_module)N)r*r0r1r4r_post_import_hooks_lockr>rrrrrsrcsfdd}|S)Ncst||S)N)r")r )rrrregisters zwhen_imported..registerr)rr@r)rr when_importeds rA)__doc__r threading version_infor6 basestringrr=str decoratorsrrrRLockr?rr"r$r)r+r,r2rrArrrrs(   7  A