a �DOg�^�@s�ddlmZddlmZddlZddlZddlZddlZddl Zddl Z ddl Z ddl m Z ddlZgd�Zedd�Zde_d d �Zd d �Zd1dd�Zd2dd�Zed3dd��Zd4dd�Ze�ejje�dd�ZGdd�d�ZGdd�d�Zz.ddlZddlmZd5dd�Z e�ee �Wne!�y.Yn0dd �Z"d6d!d"�Z#d#d$�Z$d%d&�Z%d'd(�Z&d)d*�Z'd+Z(e �)d,e(�d-e(�d.�e j*�Z+[(d/d0�Z,dS)7�)� namedtuple)�singledispatchN)� ModuleType) � get_importer�iter_importers� get_loader� find_loader� walk_packages� iter_modules�get_data� ImpImporter� ImpLoader� read_code� extend_path� ModuleInforzmodule_finder name ispkgz.A namedtuple with minimal info about a module.cCsPz |j}Wn8tyB|�|�}|dur0YdStj�||�YS0||�SdS�N)� find_spec�AttributeError� find_module� importlib�util�spec_from_loader)�finder�namer�loader�r�/usr/lib64/python3.9/pkgutil.py� _get_specs   rcCs6ddl}|�d�}|tjjkr"dS|�d�|�|�S)Nr�� )�marshal�readrr� MAGIC_NUMBER�load)�streamr �magicrrrr)s    r�c #s�ifdd��t||�D]�}|V|jrzt|j�WnJtyX|durT||j�Yqty~|durx||j�n�Yq0ttj|jdd�p�g}�fdd�|D�}t ||jd|�EdHqdS)NcSs||vr dSd||<dS)NTr)�p�mrrr�seenSszwalk_packages..seen�__path__csg|]}�|�s|�qSrr)�.0r'�r)rr� j�z!walk_packages..�.) r �ispkg� __import__r� ImportError� Exception�getattr�sys�modulesr )�path�prefix�onerror�inforr,rr 6s     r ccsr|durt�}nt|t�r$td��n tt|�}i}|D]6}t||�D]&\}}||vrDd||<t|||�VqDq6dS)Nz9path must be None or list of paths to look for modules in�)r� isinstance�str� ValueError�mapr�iter_importer_modulesr)r7r8� importers�yielded�irr0rrrr os    r cCst|d�sgS|�|�S)Nr )�hasattrr )�importerr8rrrr@�s r@c cs |jdustj�|j�sdSi}ddl}zt�|j�}WntyNg}Yn0|��|D]�}|�|�}|dks\||vr|q\tj�|j|�}d}|s�tj�|�r�d|vr�|}zt�|�} Wnty�g} Yn0| D]}|�|�} | dkr�d}q�q�q\|r\d|vr\d||<|||fVq\dS�Nr�__init__Fr/Tr;� r7�os�isdir�inspect�listdir�OSError�sort� getmodulename�join) rEr8rBrK� filenames�fn�modnamer7r0� dircontents�subnamerrr�_iter_file_finder_modules�s<       rVcCsBt���&t�dt�t�d�aWd�n1s40YdS)N�ignore�imp)�warnings�catch_warnings� simplefilter�DeprecationWarningr� import_modulerXrrrr� _import_imp�s  r^c@s*eZdZd dd�Zd dd�Zd dd�ZdS) r NcCst�dt�t�||_dS�Nz5This emulation is deprecated, use 'importlib' instead)rY�warnr\r^r7)�selfr7rrrrG�s �zImpImporter.__init__cCs~|�d�d}||kr$|jdur$dS|jdur4d}ntj�|j�g}zt�||�\}}}WntynYdS0t||||�S)Nr/�����)�splitr7rI�realpathrXrr2r )ra�fullnamer7rU�file�filename�etcrrrr�s  zImpImporter.find_moduler&c cs |jdustj�|j�sdSi}ddl}zt�|j�}WntyNg}Yn0|��|D]�}|�|�}|dks\||vr|q\tj�|j|�}d}|s�tj�|�r�d|vr�|}zt�|�} Wnty�g} Yn0| D]}|�|�} | dkr�d}q�q�q\|r\d|vr\d||<|||fVq\dSrFrH) rar8rBrKrQrRrSr7r0rTrUrrrr �s<       zImpImporter.iter_modules)N)N)r&)�__name__� __module__� __qualname__rGrr rrrrr �s  r c@sjeZdZdZZdd�Zdd�Zdd�Zdd �Zd d �Z d d �Z ddd�Z ddd�Z dd�Z ddd�ZdS)r NcCs.t�dt�t�||_||_||_||_dSr_)rYr`r\r^rfrgrerh)rarerfrgrhrrrrGs�zImpLoader.__init__cCsJ|��z*t�||j|j|j�}W|jrF|j��n|jrD|j��0|Sr)�_reopenrX� load_modulerfrgrh�close)rare�modrrrrms � zImpLoader.load_modulecCs6t|d��}|��Wd�S1s(0YdS)N�rb)�openr!)ra�pathnamerfrrrr &s zImpLoader.get_datacCsT|jrP|jjrP|jd}|tjkr2t|jd�|_n|tjtjfvrPt|jd�|_dS)N��rrp) rf�closedrhrX� PY_SOURCErqrg� PY_COMPILED� C_EXTENSION)ra�mod_typerrrrl*s   zImpLoader._reopencCs0|dur|j}n||jkr,td|j|f��|S)Nz,Loader for module %s cannot handle module %s)rer2�rarerrr� _fix_name2s �zImpLoader._fix_namecCs|�|�}|jdtjkS�Nrs)r{rhrX� PKG_DIRECTORYrzrrr� is_package:s zImpLoader.is_packagecCs�|�|�}|jdur�|jd}|tjkrD|�|�}t||jd�|_nT|tjkr�|� �zt |j �|_W|j � �q�|j � �0n|tj kr�|����|_|jS)Nrs�exec)r{�coderhrXrv� get_source�compilergrwrlrrfrnr}� _get_delegate�get_code)rarery�sourcerrrr�>s       zImpLoader.get_codecCs�|�|�}|jdur�|jd}|tjkrZ|��z|j��|_W|j��q�|j��0nx|tj kr�t j � |j dd��r�t|j dd�d��}|��|_Wd�q�1s�0Yn|tjkr�|����|_|jS)Nrsrbrt)r{r�rhrXrvrlrfr!rnrwrIr7�existsrgrqr}r�r�)rarery�frrrr�Os     * zImpLoader.get_sourcecCst|j�}t|d�}|jS)NrG)r rgrr)rar�specrrrr�as  zImpLoader._get_delegatecCsH|�|�}|jd}|tjkr*|����S|tjtjtjfvrD|j SdSr|) r{rhrXr}r�� get_filenamervrwrxrg)rareryrrrr�fs    zImpLoader.get_filename)N)N)N)rirjrkr�r�rGrmr rlr{r~r�r�r�r�rrrrr s    r )� zipimporterc cs�ttj|j�}|j}t|�}i}ddl}|D]�}|�|�s>q.||d��t j �}t|�dkr�|d�d�r�|d|vr�d||d<||ddfVt|�dkr�q.|� |d�}|dkr�q.|r.d|vr.||vr.d||<||dfVq.dS) Nrrsr;z __init__.pyTrGr/F) �sorted� zipimport�_zip_directory_cache�archiver8�lenrK� startswithrcrI�seprO) rEr8�dirlist�_prefix�plenrBrKrRrSrrr�iter_zipimport_modulests*    r�c Cstt�|�}ztj|}WnVtyntjD]8}z ||�}tj�||�WqjWq,tybYq,0q,d}Yn0|Sr)rI�fsdecoder5�path_importer_cache�KeyError� path_hooks� setdefaultr2)� path_itemrE� path_hookrrrr�s      rccs�|�d�rd�|�}t|��d|vrV|�d�d}t�|�}t|dd�}|durhdSntjEdHtj }|D]}t |�VqldS)Nr/�'Relative module name {!r} not supportedrr*) r��formatr2� rpartitionrr]r4r5� meta_pathr7r)re�msg�pkg_name�pkgr7�itemrrrr�s     rcCsn|tjvr tj|}|dur dSt|t�rb|}t|dd�}|durF|St|dd�durZdS|j}n|}t|�S)N� __loader__�__spec__)r5r6r<rr4rir)�module_or_name�modulerrerrrr�s    rc Cs�|�d�rd�|�}t|��ztj�|�}WnHttttfyt}z(d}t|�|t |�|��|�WYd}~n d}~00|dur�|j SdS)Nr/r�z,Error while finding loader for {!r} ({}: {})) r�r�r2rrrr� TypeErrorr>�typer)rer�r��exrrrr�s  .rc Cs�t|t�s|S|d}|dd�}|�d�\}}}|rdztj|j}Wqjttfy`|YS0ntj}|D�]>}t|t �s�qnt |�}|dur�g} t |d�r�|� |�} | dur�| j p�g} nt |d�r�|�|�\}} | D]} | |vr�|�| �q�tj�||�} tj�| �rnz t| �} Wn:t�yP}z tj�d| |f�WYd}~qnd}~00| �F| D]0}|�d�}|�r\|�d��r��q\|�|��q\Wd�qn1�s�0Yqn|S)Nz.pkgr/rrzCan't open %s: %s � �#)r<�listr�r5r6r*r�rr7r=rrDr�submodule_search_locationsr�appendrIrP�isfilerqrM�stderr�write�rstripr�)r7r� sname_pkg�parent_package�_� final_name� search_path�dirr�portionsr��portion�pkgfiler�r��linerrrr�sR!            � 0rcCs�tj�|�}|durdS|j}|dus0t|d�s4dStj�|�pJtj� |�}|dus^t|d�sbdS|� d�}|� dt j �|j��t j j|�}|�|�S)Nr �__file__�/r)rrrrrDr5r6�get� _bootstrap�_loadrc�insertrIr7�dirnamer�rPr )�package�resourcer�rro�parts� resource_namerrrr Ws   �  r z(?!\d)(\w+)(\.(?!\d)(\w+))*z ^(?Pz)(?P:(?Pz)?)?$c Cs�t�|�}|std|����|��}|�d�rZt�|d�}|�d�}|rT|�d�ng}nn|�d�}|�d�}t�|�}|r�|d}|�d|��}zt�|�}|�d�|}Wqxt y�Yq�Yqx0qx|}|D]}t ||�}q�|S)Nzinvalid format: �clnr��objr/r) � _NAME_PATTERN�matchr>� groupdictr�rr]rc�popr2r4) rr(�gdror�rSr'�s�resultrrr� resolve_name�s0           r�)Nr&N)Nr&)r&)r&)r&)r&)-� collectionsr� functoolsr� simplegenericr�importlib.util�importlib.machineryrIZos.path�rer5�typesrrY�__all__r�__doc__rrr r r@rV�register� machinery� FileFinderr^r r r�r�r�r2rrrrrr Z _DOTTED_WORDSr��Ur�r�rrrr�sV     9   (�Jc   ^+