3 \*@s ddlmZddlmZddlmZddlmZddlmZddlmZddlm Z ddlm Z dd lm Z dd lm Z d d l mZd d lZd d lZd d lZd d lZddZd ddZd!ddZeddZddZddZddZGdddejZGdddejZd S)")abc)module_from_spec) _resolve_name)spec_from_loader) _find_spec) MAGIC_NUMBER)cache_from_source) decode_source)source_from_cache)spec_from_file_location)contextmanagerNcCs^|jds|S|s&tdt|dd}x|D]}|dkr>P|d7}q0Wt||d||S)N.zno package specified for z% (required for relative module names)r r) startswith ValueErrorreprr)namepackagelevel characterr&/usr/lib64/python3.6/importlib/util.py resolve_names   rc Csx|tjkrt||Stj|}|dkr*dSy |j}Wn$tk rXtdj|dYnX|dkrptdj||SdS)Nz{}.__spec__ is not setz{}.__spec__ is None)sysmodulesr__spec__AttributeErrorrformat)rpathmodulespecrrr_find_spec_from_path#s    r!c Cs|jdrt||n|}|tjkrZ|jdd}|rNt|dgd}t||jSt|dSn`tj|}|dkrpdSy |j}Wn$t k rt dj |dYnX|dkrt dj ||SdS)Nrr __path__)fromlistz{}.__spec__ is not setz{}.__spec__ is None) rrrr rpartition __import__rr"rrrr)rrfullname parent_nameparentrr rrr find_specBs"     r)ccs|tjk}tjj|}|s6tt|}d|_|tj|<zJy |VWn:tk r||sxy tj|=Wntk rvYnXYnXWdd|_XdS)NTF)rrgettype__initializing__ ExceptionKeyError)r is_reloadrrrr_module_to_loadjs      r0cstjfdd}|S)NcsRtjdtdd||}t|dddkrN|j|_t|dsN|jjdd|_|S)Nz7The import system now takes care of this automatically.) stacklevel __package__r"rr )warningswarnDeprecationWarninggetattr__name__r3hasattrr$)argskwargsr)fxnrrset_package_wrappers   z(set_package..set_package_wrapper) functoolswraps)r<r=r)r<r set_packages r@cstjfdd}|S)Ncs:tjdtdd|f||}t|dddkr6||_|S)Nz7The import system now takes care of this automatically.r1)r2 __loader__)r4r5r6r7rA)selfr:r;r)r<rrset_loader_wrappers  z&set_loader..set_loader_wrapper)r>r?)r<rCr)r<r set_loadersrDcs*tjdtddtjfdd}|S)Nz7The import system now takes care of this automatically.r1)r2cspt|^}||_y|j|}Wnttfk r6YnX|rD||_n|jdd|_||f||SQRXdS)Nrr )r0rA is_package ImportErrorrr3r$)rBr&r:r;rrE)r<rrmodule_for_loader_wrappers z4module_for_loader..module_for_loader_wrapper)r4r5r6r>r?)r<rGr)r<rmodule_for_loaders rHc@seZdZddZddZdS) _LazyModulec Cstj|_|jj}|jjd}|jjd}|j}i}xF|jD]:\}}||krV|||<q sz$LazyLoader.factory..)_LazyLoader__check_eager_loader)rdrQr)rdrQrfactorys zLazyLoader.factorycCs|j|||_dS)N)rfrQ)rBrQrrr__init__ s zLazyLoader.__init__cCs |jj|S)N)rQ create_module)rBr rrrriszLazyLoader.create_modulecCs@|j|j_|j|_i}|jj|d<|j|d<||j_t|_dS)NrJrK)rQrrArJcopyrKrNrI)rBrrNrrrrRs  zLazyLoader.exec_moduleN) r8r_r` staticmethodrf classmethodrgrhrirRrrrrras   ra)N)N)r _bootstraprrrr_bootstrap_externalrrr r r contextlibr r>rrLr4rr!r)r0r@rDrHrMrILoaderrarrrrs.             ( '/