a Z^9,@s(ddlmZddlmZddlmZddlmZddlmZddlmZddlm Z ddlm Z dd lm Z dd lm Z dd lm Z d d lmZd dlZd dlZd dlZd dlZd dlZddZddZd#ddZd$ddZeddZddZddZddZGdd d ejZGd!d"d"ejZ dS)%)abc)module_from_spec) _resolve_name)spec_from_loader) _find_spec) MAGIC_NUMBER)_RAW_MAGIC_NUMBER)cache_from_source) decode_source)source_from_cache)spec_from_file_location)contextmanagerNcCs tt|SN)_imp source_hashr) source_bytesr&/usr/lib64/python3.9/importlib/util.pyrsrcCs\|ds|S|s&tdt|dd}|D]}|dkr>qH|d7}q.t||d||S)N.zno package specified for z% (required for relative module names)r r) startswith ImportErrorreprr)namepackagelevel characterrrr resolve_names   rcCsv|tjvrt||Stj|}|dur*dSz |j}Wn"tyVtd|dYn0|durntd||SdS)N{}.__spec__ is not set{}.__spec__ is None)sysmodulesr__spec__AttributeError ValueErrorformat)rpathmodulespecrrr_find_spec_from_path*s     r)c Cs|drt||n|}|tjvr|dd}|rt|dgd}z |j}Wqty}z&td|d||d|WYd}~qd}~00nd}t ||Stj|}|durdSz |j }Wn"tyt d |dYn0|durt d ||SdS) Nrr __path__)fromlistz __path__ attribute not found on z while trying to find )rrr) rrr r! rpartition __import__r*r#ModuleNotFoundErrorrr"r$r%) rrfullname parent_nameparent parent_pather'r(rrr find_specIs<      r4c cs|tjv}tj|}|s6tt|}d|_|tj|<zLz |VWn6tyx|stz tj|=WntyrYn0Yn0Wd|_nd|_0dS)NTF)r r!gettype__initializing__ ExceptionKeyError)r is_reloadr'rrr_module_to_loadvs        r;cstfdd}|S)NcsVtjdtdd|i|}t|dddurR|j|_t|dsR|jdd|_|S)N7The import system now takes care of this automatically. stacklevel __package__r*rr )warningswarnDeprecationWarninggetattr__name__r@hasattrr,)argskwargsr'fxnrrset_package_wrappers z(set_package..set_package_wrapper functoolswraps)rJrKrrIr set_packages rOcstfdd}|S)Ncs@tjdtdd|g|Ri|}t|dddur<||_|S)Nr<r=r> __loader__)rArBrCrDrP)selfrGrHr'rIrrset_loader_wrappersz&set_loader..set_loader_wrapperrL)rJrRrrIr set_loadersrScs*tjdtddtfdd}|S)Nr<r=r>c st|p}||_z||}Wnttfy4Yn0|rB||_n|dd|_||g|Ri|WdS1s~0YdS)Nrr )r;rP is_packagerr#r@r,)rQr/rGrHr'rTrIrrmodule_for_loader_wrappers z4module_for_loader..module_for_loader_wrapper)rArBrCrMrN)rJrUrrIrmodule_for_loaders rVc@seZdZddZddZdS) _LazyModulec Cstj|_|jj}|jjd}|jjd}|j}i}|D]:\}}||vrT|||<q:t||t||kr:|||<q:|jj ||t j vrt|tt j |krt d|d|j|t||S)N__dict__ __class__zmodule object for z. substituted in sys.modules during a lazy load)types ModuleTyperYr"r loader_staterXitemsidloader exec_moduler r!r$updaterD) rQattr original_name attrs_then original_type attrs_now attrs_updatedkeyvaluerrr__getattribute__s&       z_LazyModule.__getattribute__cCs||t||dSr)rjdelattr)rQrbrrr __delattr__s z_LazyModule.__delattr__N)rE __module__ __qualname__rjrlrrrrrWs#rWc@s<eZdZeddZeddZddZddZd d Z d S) LazyLoadercCst|dstddS)Nr`z loader must define exec_module())rF TypeError)r_rrr__check_eager_loaders zLazyLoader.__check_eager_loadercsfddS)Ncs|i|Srr)rGrHclsr_rrz$LazyLoader.factory..)_LazyLoader__check_eager_loaderrrrrrrfactorys zLazyLoader.factorycCs||||_dSr)rvr_)rQr_rrr__init__s zLazyLoader.__init__cCs |j|Sr)r_ create_module)rQr(rrrryszLazyLoader.create_modulecCs@|j|j_|j|_i}|j|d<|j|d<||j_t|_dS)NrXrY)r_r"rPrXcopyrYr\rW)rQr'r\rrrr` s  zLazyLoader.exec_moduleN) rErmrn staticmethodrv classmethodrwrxryr`rrrrro s  ro)N)N)!r _bootstraprrrr_bootstrap_externalrrr r r r contextlibrrrMr rZrArrr)r4r;rOrSrVr[rWLoaderrorrrrs6              - '/