@contextmanager
def _check_require_version(namespace, stacklevel):
 repository = GIRepository()
 was_loaded = repository.is_registered(namespace)
 (yield)
 if was_loaded:
  return
 if (namespace in ('GLib', 'GObject', 'Gio')):
  return
 if (get_required_version(namespace) is not None):
  return
 version = repository.get_version(namespace)
 warnings.warn(("%(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': namespace, 'version': version}), PyGIWarning, stacklevel=stacklevel)

@ contextmanager def _check_require_version ( namespace , stacklevel ) : repository = GIRepository ( ) was_loaded = repository . is_registered ( namespace ) ( yield ) if was_loaded : return if ( namespace in ( 'GLib' , 'GObject' , 'Gio' ) ) : return if ( get_required_version ( namespace ) is not None ) : return version = repository . get_version ( namespace ) warnings . warn ( ( "%(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' : namespace , 'version' : version } ) , PyGIWarning , stacklevel = stacklevel )
a context manager which tries to give helpful warnings about missing gi .