3 ��<_��@s�ddlmZddlZddlZddlZddlmZddlZddlm Z m Z ddlm Z ddl m Z ddlmZe j�ZiZed d ��Zd d �ZGd d�de�ZdS)�)�absolute_importN)�contextmanager�)� Repository�RepositoryError)� PyGIWarning)�get_introspection_module)�load_overridesccs^tj|�}dV|rdS|dkr$dStj|�dk r6dStj|�}tjd||d�t|d�dS) aOA context manager which tries to give helpful warnings about missing gi.require_version() which could potentially break code if only an older version than expected is installed or a new version gets introduced. :: with _check_require_version("Gtk", stacklevel): load_namespace_and_overrides() N�GLib�GObject�Gioz�%(namespace)s was imported without specifying a version first. Use gi.require_version('%(namespace)s', '%(version)s') before import to ensure that the right version gets loaded.)� namespace�version)� stacklevel)r r r )� repository� is_registered�giZget_required_versionZ get_version�warnings�warnr)r rZ was_loadedr�r� /usr/lib64/python3.6/importer.py�_check_require_version+s   rcCsZtjdd�}|dkr"|rdSdS|dkr6|r2dSdS|d krJ|rFdSdS|rRdSdSdS) a2Returns the stacklevel value for warnings.warn() for when the warning gets emitted by an imported module, but the warning should point at the code doing the import. Pass import_hook=True if the warning gets generated by an import hook (warn() gets called in load_module(), see PEP302) N����� )rr)rr)rr)�sys� version_info)� import_hook� py_versionrrr�get_import_stacklevelRs    r!c@s&eZdZdd�Zddd�Zdd�ZdS) �DynamicImportercCs ||_dS)N)�path)�selfr#rrr�__init__lszDynamicImporter.__init__NcCsV|j|j�sdS|jdd�\}}||jkr.dStj|�sBtj|�rF|Std|��dS)N�.rz6cannot import name %s, introspection typelib not found)� startswithr#�rsplitrrZenumerate_versions� ImportError)r$�fullnamer#r rrr� find_moduleos    zDynamicImporter.find_modulec Cs�|tjkrtj|S|jdd�\}}tdd�}t||d��ry t|�}Wn*tk rr}zt|��WYdd}~XnXx*tj |�D]}t j d|j d�d�q�Wt |�}WdQRXd ||_||_|tj|<|S) Nr&rT)r)rzgi.repository.�-rz<%s>)r�modulesr(r!rrrr)rZget_immediate_dependencies� importlib� import_module�splitr �__file__� __loader__) r$r*r#r rZintrospection_module�eZdepZdynamic_modulerrr� load_module�s       zDynamicImporter.load_module)N)�__name__� __module__� __qualname__r%r+r4rrrrr"hs r")Z __future__rrrr.� contextlibrrZ_girrr�modulerZ overridesr Z get_defaultrr-rr!�objectr"rrrr�s      '