U
    g()                     @   s  d Z ddlmZmZmZmZmZmZmZm	Z	m
Z
 zddlmZ W n ek
rX   dZY nX ddlmZmZmZmZ ddlmZ ddlmZ ddlmZ ddlZddlZddlZddlZddlZddlZejd	ed
d dZdZd
Z dZ!dZ"dZ#dZ$dZ%dZ&dZ'dd Z(dd Z)dd Z*d8ddZ+dd Z,dd Z-G d d! d!Z.G d"d# d#Z/G d$d% d%e/ej0Z1d9d&d'Z2G d(d) d)e/eZ3d:d*d+Z4d,d- Z5d.d/ Z6d;d0d1Z7d2d3 Z8d4d5 Z9erd<d6d7Z:ndZ:dS )=zThis module provides the components needed to build your own __import__
function.  Undocumented functions are obsolete.

In most cases it is preferred you consider using the importlib module's
functionality over this module.

    )		lock_heldacquire_lockrelease_lockget_frozen_objectis_frozen_packageinit_frozen
is_builtin	is_frozen_fix_co_filename)create_dynamicN)_ERR_MSG_exec_load_builtin_from_name)SourcelessFileLoader)	machinery)utilzhthe imp module is deprecated in favour of importlib; see the module's documentation for alternative uses   )
stacklevel                     	   c                 C   s
   t | S )z_**DEPRECATED**

    Create a new module.

    The module is not entered into sys.modules.

    )types
ModuleTypename r!   /usr/lib/python3.8/imp.py
new_module0   s    r#   c                   C   s   t jS )z@**DEPRECATED**

    Return the magic number for .pyc files.
    )r   MAGIC_NUMBERr!   r!   r!   r"   	get_magic;   s    r%   c                   C   s   t jjS )z$Return the magic tag for .pyc files.)sysimplementation	cache_tagr!   r!   r!   r"   get_tagC   s    r)   c              
   C   s6   t  $ t d t| |W  5 Q R  S Q R X dS )a  **DEPRECATED**

    Given the path to a .py file, return the path to its .pyc file.

    The .py file does not need to exist; this simply returns the path to the
    .pyc file calculated as if the .py file were imported.

    If debug_override is not None, then it must be a boolean and is used in
    place of sys.flags.optimize.

    If sys.implementation.cache_tag is None then NotImplementedError is raised.

    ignoreN)warningscatch_warningssimplefilterr   cache_from_source)pathdebug_overrider!   r!   r"   r.   H   s    

r.   c                 C   s
   t | S )a~  **DEPRECATED**

    Given the path to a .pyc. file, return the path to its .py file.

    The .pyc file does not need to exist; this simply returns the path to
    the .py file calculated to correspond to the .pyc file.  If path does
    not conform to PEP 3147 format, ValueError will be raised. If
    sys.implementation.cache_tag is None then NotImplementedError is raised.

    )r   source_from_cacher/   r!   r!   r"   r1   [   s    r1   c                  C   s<   dd t jD } dd t jD }dd t jD }| | | S )**DEPRECATED**c                 S   s   g | ]}|d t fqS rb)C_EXTENSION.0sr!   r!   r"   
<listcomp>k   s     z get_suffixes.<locals>.<listcomp>c                 S   s   g | ]}|d t fqS )r)	PY_SOURCEr7   r!   r!   r"   r:   l   s     c                 S   s   g | ]}|d t fqS r4   )PY_COMPILEDr7   r!   r!   r"   r:   m   s     )r   EXTENSION_SUFFIXESSOURCE_SUFFIXESBYTECODE_SUFFIXES)
extensionssourcebytecoder!   r!   r"   get_suffixesi   s    rD   c                   @   s    e Zd ZdZdd Zdd ZdS )NullImporterz-**DEPRECATED**

    Null import object.

    c                 C   s2   |dkrt dddntj|r.t d|dd S )N zempty pathnamer2   zexisting directory)ImportErrorosr/   isdir)selfr/   r!   r!   r"   __init__z   s    zNullImporter.__init__c                 C   s   dS )zAlways returns None.Nr!   )rJ   fullnamer!   r!   r"   find_module   s    zNullImporter.find_moduleN)__name__
__module____qualname____doc__rK   rM   r!   r!   r!   r"   rE   r   s   rE   c                       s.   e Zd ZdZd fdd	Z fddZ  ZS )_HackedGetDatazMCompatibility support for 'file' arguments of various load_*()
    functions.Nc                    s   t  || || _d S )N)superrK   file)rJ   rL   r/   rT   	__class__r!   r"   rK      s    z_HackedGetData.__init__c              
      s|   | j rl|| jkrl| j js0| j }d|jkr0|  | j jrJt| jd | _ }| | W  5 Q R  S Q R X nt |S dS )z;Gross hack to contort loader to deal w/ load_*()'s bad API.br5   N)	rT   r/   closedmodecloseopenreadrS   get_data)rJ   r/   rT   rU   r!   r"   r]      s    
z_HackedGetData.get_data)N)rN   rO   rP   rQ   rK   r]   __classcell__r!   r!   rU   r"   rR      s   rR   c                   @   s   e Zd ZdZdS )_LoadSourceCompatibilityz5Compatibility support for implementing load_source().NrN   rO   rP   rQ   r!   r!   r!   r"   r_      s   r_   c                 C   s\   t | ||}tj| ||d}| tjkr8t|tj|  }nt|}t| ||_	|j	|j
_|S )Nloader)r_   r   spec_from_file_locationr&   modulesr   r   r   SourceFileLoader
__loader____spec__rb   r    pathnamerT   rb   specmoduler!   r!   r"   load_source   s    

rl   c                   @   s   e Zd ZdZdS )_LoadCompiledCompatibilityz7Compatibility support for implementing load_compiled().Nr`   r!   r!   r!   r"   rm      s   rm   c                 C   sZ   t | ||}tj| ||d}| tjkr8t|tj|  }nt|}t| ||_|j|j	_
|S )r3   ra   )rm   r   rc   r&   rd   r   r   r   rf   rg   rb   rh   r!   r!   r"   load_compiled   s    

rn   c                 C   s   t j|rftjdd tjdd  }|D ]*}t j|d| }t j|r,|} qfq,td	|t
j| |g d}| tjkrt|tj|  S t|S dS )r3   NrK   z{!r} is not a package)submodule_search_locations)rH   r/   rI   r   r?   r@   joinexists
ValueErrorformatr   rc   r&   rd   r   r   )r    r/   rA   	extensionZ	init_pathrj   r!   r!   r"   load_package   s     
ru   c           	   
   C   s$  |\}}}|r0| dr d|kr0td|n|dkrX|tthkrXd|}t|n|tkrlt| ||S |tkrt| ||S |tkrtdk	r|dkrt	|d}t| ||W  5 Q R  S Q R X nt| ||S nN|t
krt| |S |tk rt| S |tkrt| S d| |}t|| ddS )	z**DEPRECATED**

    Load a module, given information returned by find_module().

    The module name must include the full package name, if any.

    )r;   U+zinvalid file open mode {!r}Nz.file object required for import (type code {})r5   z*Don't know how to import {} (type code {})r   )
startswithrr   rs   r<   r=   rl   rn   r6   load_dynamicr[   PKG_DIRECTORYru   	C_BUILTINinit_builtin	PY_FROZENr   rG   )	r    rT   filenameZdetailssuffixrY   type_msgZopened_filer!   r!   r"   load_module   s.    


 


r   c              	   C   s  t | tstdt| n$t |tdtfsBtdt||dkrt| rbddddtffS t	| rzddddt
ffS tj}|D ]}tj|| }dtjd fD ]>}d| }tj||}tj|rd|ddtff    S qt D ]2\}}}| | }	tj||	}tj|r q qq q:qtt| | dd}
d	|krnt|d
}t|jd }
W 5 Q R X t|||
d}|||||ffS )a,  **DEPRECATED**

    Search for a module.

    If path is omitted or None, search for a built-in, frozen or special
    module and continue search in sys.path. The module name cannot
    contain '.'; to search for a submodule of a package, pass the
    submodule name and the package's __path__.

    z'name' must be a str, not {}Nz%'path' must be None or a list, not {}rF   z.pyr   rK   r   rW   r5   )encoding)
isinstancestr	TypeErrorrs   typelistRuntimeErrorr   r{   r	   r}   r&   r/   rH   rp   r   r@   isfilerz   rD   rG   r   r[   tokenizedetect_encodingreadline)r    r/   entryZpackage_directoryr   Zpackage_file_nameZ	file_pathrY   r   	file_namer   rT   r!   r!   r"   rM      sB    

rM   c                 C   s
   t | S )zw**DEPRECATED**

    Reload the module and return it.

    The module must have been successfully imported before.

    )	importlibreload)rk   r!   r!   r"   r   2  s    r   c                 C   s&   z
t | W S  tk
r    Y dS X dS )zl**DEPRECATED**

    Load and return a built-in module by name, or None is such module doesn't
    exist
    N)r   rG   r   r!   r!   r"   r|   =  s    
r|   c                 C   s0   ddl }|j| |}|jj| ||d}t|S )z:**DEPRECATED**

        Load an extension module.
        r   N)r    rb   origin)importlib.machineryr   ExtensionFileLoader
ModuleSpecr   )r    r/   rT   r   rb   rj   r!   r!   r"   ry   J  s      ry   )N)N)N)N)N);rQ   _impr   r   r   r   r   r   r   r	   r
   r   rG   Zimportlib._bootstrapr   r   r   r   importlib._bootstrap_externalr   r   r   r   rH   r&   r   r   r+   warnDeprecationWarningZSEARCH_ERRORr<   r=   r6   ZPY_RESOURCErz   r{   r}   ZPY_CODERESOURCEZIMP_HOOKr#   r%   r)   r.   r1   rD   rE   rR   re   r_   rl   rm   rn   ru   r   rM   r   r|   ry   r!   r!   r!   r"   <module>   sb   ,
 
	

#
4