3 <_@sddlmZddlZddlZddlZddlmZddlZddlm Z m Z ddlm Z ddl m Z ddlmZe jZiZed d Zd d ZGd ddeZdS))absolute_importN)contextmanager) RepositoryRepositoryError) PyGIWarning)get_introspection_module)load_overridesccs^tj|}dV|rdS|dkr$dStj|dk r6dStj|}tjd||dt|ddS) 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() NGLibGObjectGioz%(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.) namespaceversion) stacklevel)r r r ) repository is_registeredgiZget_required_versionZ get_versionwarningswarnr)r rZ was_loadedrr /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_versionrrrget_import_stacklevelRs    r!c@s&eZdZddZdddZddZdS) DynamicImportercCs ||_dS)N)path)selfr#rrr__init__lszDynamicImporter.__init__NcCsV|j|jsdS|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||dry t|}Wn*tk rr}zt|WYdd}~XnXx*tj |D]}t j d|j ddqWt |}WdQRXd ||_||_|tj|<|S) Nr&rT)r)rzgi.repository.-rz<%s>)rmodulesr(r!rrrr)rZget_immediate_dependencies importlib import_modulesplitr __file__ __loader__) r$r*r#r rZintrospection_moduleeZdepZdynamic_modulerrr load_modules       zDynamicImporter.load_module)N)__name__ __module__ __qualname__r%r+r4rrrrr"hs r")Z __future__rrrr. contextlibrrZ_girrrmodulerZ overridesr Z get_defaultrr-rr!objectr"rrrrs      '