U e5d7,@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.8/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 ValueErrorreprr)namepackagelevel characterrrr resolve_names  rcCsx|tjkrt||Stj|}|dkr*dSz |j}Wn$tk rXtd|dYnX|dkrptd||SdS)N{}.__spec__ is not set{}.__spec__ is None)sysmodulesr__spec__AttributeErrorrformat)rpathmodulespecrrr_find_spec_from_path*s    r(c Cs|drt||n|}|tjkr|dd}|rt|dgd}z |j}Wqtk r}ztd|d||d|W5d}~XYqXnd}t ||Stj|}|dkrdSz |j }Wn$tk rt d |dYnX|dkrt d ||SdS) Nrr __path__)fromlistz __path__ attribute not found on z while trying to find )rrr) rrr r! rpartition __import__r)r#ModuleNotFoundErrorrr"rr$) rrfullname parent_nameparent parent_pather&r'rrr find_specIs4     r3c cs|tjk}tj|}|s6tt|}d|_|tj|<zJz |VWn:tk r||sxz tj|=Wntk rvYnXYnXW5d|_XdS)NTF)r r!gettype__initializing__ ExceptionKeyError)r is_reloadr&rrr_module_to_loadvs      r:cstfdd}|S)NcsRtjdtdd||}t|dddkrN|j|_t|dsN|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)rIrJrrHr set_packages rNcstfdd}|S)Ncs:tjdtdd|f||}t|dddkr6||_|S)Nr;r<r= __loader__)r@rArBrCrO)selfrFrGr&rHrrset_loader_wrappersz&set_loader..set_loader_wrapperrK)rIrQrrHr set_loadersrRcs*tjdtddtfdd}|S)Nr;r<r=c s|t|j}||_z||}Wnttfk r6YnX|rD||_n|dd|_||f||W5QRSQRXdS)Nrr )r:rO is_package ImportErrorr#r?r+)rPr.rFrGr&rSrHrrmodule_for_loader_wrappers z4module_for_loader..module_for_loader_wrapper)r@rArBrLrM)rIrUrrHrmodule_for_loadersrVc@seZdZddZddZdS) _LazyModulec Cstj|_|jj}|jjd}|jjd}|j}i}|D]:\}}||krT|||<q:t||t||kr:|||<q:|jj ||t j krt|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!rupdaterC) rPattr original_name attrs_then original_type attrs_now attrs_updatedkeyvaluerrr__getattribute__s"      z_LazyModule.__getattribute__cCs||t||dSr)rjdelattr)rPrbrrr __delattr__s z_LazyModule.__delattr__N)rD __module__ __qualname__rjrlrrrrrWs#rWc@s<eZdZeddZeddZddZddZd d Z d S) LazyLoadercCst|dstddS)Nr`z loader must define exec_module())rE TypeError)r_rrr__check_eager_loaders zLazyLoader.__check_eager_loadercsfddS)Ncs||Srr)rFrGclsr_rrz$LazyLoader.factory..)_LazyLoader__check_eager_loaderrrrrrrfactorys zLazyLoader.factorycCs||||_dSr)rvr_)rPr_rrr__init__s zLazyLoader.__init__cCs |j|Sr)r_ create_module)rPr'rrrryszLazyLoader.create_modulecCs@|j|j_|j|_i}|j|d<|j|d<||j_t|_dS)NrXrY)r_r"rOrXcopyrYr\rW)rPr&r\rrrr` s  zLazyLoader.exec_moduleN) rDrmrn staticmethodrv classmethodrwrxryr`rrrrro s  ro)N)N)!r _bootstraprrrr_bootstrap_externalrrr r r r contextlibrrrLr rZr@rrr(r3r:rNrRrVr[rWLoaderrorrrrs6              - '/