B ¯= ÷i”hã @stddlmZddlmZddlZddlZddlZddlZddl Zddl Z ddl m Z ddl Z ddddd d d d d dddg ZeddƒZde_dd„Zdd„Zd*dd „Zd+dd „Zed,dd„ƒZd-dd„Ze ejje¡dd„ZGdd „d ƒZGd d „d ƒZy.ddlZdd!lmZd.d"d#„Ze ee¡Wne k r<YnXd$d„Z!d/d%d„Z"d&d„Z#d'd„Z$d(d„Z%d)d „Z&dS)0é)Ú namedtuple)ÚsingledispatchN)Ú ModuleTypeÚ get_importerÚiter_importersÚ get_loaderÚ find_loaderÚ walk_packagesÚ iter_modulesÚget_dataÚ ImpImporterÚ ImpLoaderÚ read_codeÚ extend_pathÚ ModuleInfozmodule_finder name ispkgz.A namedtuple with minimal info about a module.cCsLy |j}Wn4tk r>| |¡}|dkr0dStj ||¡SX||ƒSdS)N)Ú find_specÚAttributeErrorÚ find_moduleÚ importlibÚutilÚspec_from_loader)ÚfinderÚnamerÚloader©rú*/opt/alt/python37/lib/python3.7/pkgutil.pyÚ _get_specs  rcCs6ddl}| d¡}|tjjkr"dS| d¡| |¡S)Nréé )ÚmarshalÚreadrrÚ MAGIC_NUMBERÚload)ÚstreamrÚmagicrrrr(s    Úc #sÐifdd„‰x¾t||ƒD]°}|V|jryt|jƒWnNtk r\|dk rX||jƒYqtk r„|dk r~||jƒn‚YqXttj|jddƒpœg}‡fdd„|Dƒ}t ||jd|ƒEdHqWdS)NcSs||kr dSd||<dS)NTr)ÚpÚmrrrÚseenRszwalk_packages..seenÚ__path__csg|]}ˆ|ƒs|‘qSrr)Ú.0r&)r(rrú isz!walk_packages..Ú.) r ÚispkgÚ __import__rÚ ImportErrorÚ ExceptionÚgetattrÚsysÚmodulesr )ÚpathÚprefixÚonerrorÚinfor)r(rr 5s   ccsz|dkrtƒ}nt|tƒr$tdƒ‚n tt|ƒ}i}xB|D]:}x4t||ƒD]&\}}||krHd||<t|||ƒVqHWq8WdS)Nz9path must be None or list of paths to look for modules iné)rÚ isinstanceÚstrÚ ValueErrorÚmaprÚiter_importer_modulesr)r4r5Z importersÚyieldedÚirr-rrrr ns     cCst|dƒsgS| |¡S)Nr )Úhasattrr )Úimporterr5rrrr=ˆs r=c cs0|jdkstj |j¡sdSi}ddl}yt |j¡}Wntk rPg}YnX| ¡xÐ|D]È}| |¡}|dks`||kr€q`tj |j|¡}d}|stj |¡rd|kr|}yt |¡} Wntk rÜg} YnXx&| D]}| |¡} | dkräd}PqäWq`|r`d|kr`d||<|||fVq`WdS)NrÚ__init__Fr,Tr8) r4ÚosÚisdirÚinspectÚlistdirÚOSErrorÚsortÚ getmodulenameÚjoin) rAr5r>rEÚ filenamesÚfnÚmodnamer4r-Ú dircontentsÚsubnamerrrÚ_iter_file_finder_moduless<       rPc Cs.t ¡t dt¡t d¡aWdQRXdS)NÚignoreÚimp)ÚwarningsÚcatch_warningsÚ simplefilterÚDeprecationWarningrÚ import_modulerRrrrrÚ _import_imp¼s  rXc@s*eZdZd dd„Zd dd„Zd dd„ZdS) r NcCst dt¡tƒ||_dS)Nz5This emulation is deprecated, use 'importlib' instead)rSÚwarnrVrXr4)Úselfr4rrrrBÍszImpImporter.__init__cCs~| d¡d}||kr$|jdkr$dS|jdkr4d}ntj |j¡g}yt ||¡\}}}Wntk rndSXt||||ƒS)Nr,éÿÿÿÿ)Úsplitr4rCÚrealpathrRrr/r )rZÚfullnamer4rOÚfileÚfilenameÚetcrrrrÔs zImpImporter.find_moduler%c cs0|jdkstj |j¡sdSi}ddl}yt |j¡}Wntk rPg}YnX| ¡xÐ|D]È}| |¡}|dks`||kr€q`tj |j|¡}d}|stj |¡rd|kr|}yt |¡} Wntk rÜg} YnXx&| D]}| |¡} | dkräd}PqäWq`|r`d|kr`d||<|||fVq`WdS)NrrBFr,Tr8) r4rCrDrErFrGrHrIrJ) rZr5r>rErKrLrMr4r-rNrOrrrr ãs<       zImpImporter.iter_modules)N)N)r%)Ú__name__Ú __module__Ú __qualname__rBrr rrrrr Âs  c@sjeZdZdZZdd„Zdd„Zdd„Zdd „Zd d „Z d d „Z ddd„Z ddd„Z dd„Z ddd„ZdS)r NcCs.t dt¡tƒ||_||_||_||_dS)Nz5This emulation is deprecated, use 'importlib' instead)rSrYrVrXr_r`r^ra)rZr^r_r`rarrrrBszImpLoader.__init__cCs:| ¡zt ||j|j|j¡}Wd|jr4|j ¡X|S)N)Ú_reopenrRÚ load_moduler_r`raÚclose)rZr^Úmodrrrrfs  zImpLoader.load_modulec Cst|dƒ }| ¡SQRXdS)NÚrb)Úopenr )rZÚpathnamer_rrrr %s zImpLoader.get_datacCsT|jrP|jjrP|jd}|tjkr2t|jdƒ|_n|tjtjfkrPt|jdƒ|_dS)NéÚrri) r_ÚclosedrarRÚ PY_SOURCErjr`Ú PY_COMPILEDÚ C_EXTENSION)rZÚmod_typerrrre)s   zImpLoader._reopencCs0|dkr|j}n||jkr,td|j|fƒ‚|S)Nz,Loader for module %s cannot handle module %s)r^r/)rZr^rrrÚ _fix_name1s  zImpLoader._fix_namecCs| |¡}|jdtjkS)Nrl)rsrarRÚ PKG_DIRECTORY)rZr^rrrÚ is_package9s zImpLoader.is_packagecCs”| |¡}|jdkrŽ|jd}|tjkrD| |¡}t||jdƒ|_nJ|tjkrv|  ¡zt |j ƒ|_Wd|j   ¡Xn|tj krŽ| ¡ ¡|_|jS)NrlÚexec)rsÚcoderarRroÚ get_sourceÚcompiler`rprerr_rgrtÚ _get_delegateÚget_code)rZr^rrÚsourcerrrr{=s       zImpLoader.get_codec Csº| |¡}|jdkr´|jd}|tjkrP| ¡z|j ¡|_Wd|j ¡Xnd|tj krœt j   |j dd…¡r´t|j dd…dƒ}| ¡|_WdQRXn|tjkr´| ¡ ¡|_|jS)Nrlr[rm)rsr|rarRrorer_r rgrprCr4Úexistsr`rjrtrzrx)rZr^rrÚfrrrrxNs      zImpLoader.get_sourcecCst|jƒ}t|dƒ}|jS)NrB)r r`rr)rZrÚspecrrrrz`s  zImpLoader._get_delegatecCsH| |¡}|jd}|tjkr*| ¡ ¡S|tjtjtjfkrD|j SdS)Nrl) rsrarRrtrzÚ get_filenamerorprqr`)rZr^rrrrrr€es    zImpLoader.get_filename)N)N)N)rbrcrdrwr|rBrfr rersrur{rxrzr€rrrrr s    )Ú zipimporterc csðttj|jƒ}|j}t|ƒ}i}ddl}xÀ|D]¸}| |¡s@q0||d… t j ¡}t|ƒdkr˜|d d¡r˜|d|kr˜d||d<||ddfVt|ƒdkr¦q0|  |d¡}|dkr¾q0|r0d|kr0||kr0d||<||dfVq0WdS) Nrrlr8z __init__.pyTrBr,F) ÚsortedÚ zipimportÚ_zip_directory_cacheÚarchiver5ÚlenrEÚ startswithr\rCÚseprI) rAr5ZdirlistÚ_prefixZplenr>rErLrMrrrÚiter_zipimport_modulesss*     rŠc Csnytj|}WnZtk rhxDtjD]6}y||ƒ}tj ||¡PWq&tk rZYq&Xq&Wd}YnX|S)N)r2Úpath_importer_cacheÚKeyErrorÚ path_hooksÚ setdefaultr/)Z path_itemrAÚ path_hookrrrr•s    ccs„| d¡rd |¡}t|ƒ‚d|krV| d¡d}t |¡}t|ddƒ}|dkrhdSntjEdHtj }x|D]}t |ƒVqnWdS)Nr,z'Relative module name {!r} not supportedrr)) r‡Úformatr/Ú rpartitionrrWr1r2Ú meta_pathr4r)r^ÚmsgZpkg_nameZpkgr4Úitemrrrr­s      cCsn|tjkr tj|}|dkr dSt|tƒrb|}t|ddƒ}|dk rF|St|ddƒdkrZdS|j}n|}t|ƒS)NÚ __loader__Ú__spec__)r2r3r9rr1rbr)Zmodule_or_nameÚmodulerr^rrrrÊs    c Cs†| d¡rd |¡}t|ƒ‚ytj |¡}WnFttttfk rr}z d}t| |t |ƒ|¡ƒ|‚Wdd}~XYnX|dk r‚|j SdS)Nr,z'Relative module name {!r} not supportedz,Error while finding loader for {!r} ({}: {})) r‡rr/rrrrÚ TypeErrorr;Útyper)r^r“rZexrrrrâs  *c Cs¨t|tƒs|S|d}|dd…}| d¡\}}}|rbytj|j}Wqhttfk r^|SXntj}x8|D].}t|t ƒs‚qpt |ƒ}|dk rög} t |dƒr¾|  |¡} | dk rÖ| j pºg} nt |dƒrÖ| |¡\}} x| D]} | |krÜ| | ¡qÜWtj ||¡} tj | ¡rpy t| ƒ} Wn8tk rT}ztj d| |f¡Wdd}~XYqpX| @x8| D]0}| d¡}|rb| d¡r†qb| |¡qbWWdQRXqpW|S)Nz.pkgr,rrzCan't open %s: %s Ú ú#)r9Úlistr‘r2r3r)rŒrr4r:rr@rÚsubmodule_search_locationsrÚappendrCrJÚisfilerjrGÚstderrÚwriteÚrstripr‡)r4rZ sname_pkgZparent_packageÚ_Z final_nameZ search_pathÚdirrÚportionsrZportionZpkgfiler~r“Úlinerrrr÷sP!            cCs˜tj |¡}|dkrdS|j}|dks0t|dƒs4dStj |¡pJtj  |¡}|dks^t|dƒsbdS|  d¡}|  dt j  |j¡¡t j j|Ž}| |¡S)Nr Ú__file__ú/r)rrrrr@r2r3ÚgetÚ _bootstrapÚ_loadr\ÚinsertrCr4Údirnamer§rJr )ÚpackageÚresourcerrrhÚpartsZ resource_namerrrr Us     )Nr%N)Nr%)r%)r%)r%)r%)'Ú collectionsrÚ functoolsrZ simplegenericrÚimportlib.utilZimportlib.machineryrCZos.pathr2ÚtypesrrSÚ__all__rÚ__doc__rrr r r=rPÚregisterÚ machineryÚ FileFinderrXr r rƒrrŠr/rrrrrr rrrrÚsP     9   ( Jc   ^