summaryrefslogtreecommitdiff
path: root/gi/__init__.py
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2017-07-12 08:41:54 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2017-07-12 08:41:58 +0900
commit4bfc3de521c8d93613e5153028da35406609a64f (patch)
tree98175ed0ab42bc56bec3d45d69364a988a00de1f /gi/__init__.py
parent5a89ec21697bd9e08c9102b2a7b6c60b4652e66c (diff)
downloadpygobject2-4bfc3de521c8d93613e5153028da35406609a64f.tar.gz
pygobject2-4bfc3de521c8d93613e5153028da35406609a64f.tar.bz2
pygobject2-4bfc3de521c8d93613e5153028da35406609a64f.zip
Imported Upstream version 3.13.2
Change-Id: Icce9be2c1bf0568fc95f75ff0a714c017e6171ec Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'gi/__init__.py')
-rw-r--r--gi/__init__.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/gi/__init__.py b/gi/__init__.py
index 7c1a279..df6843c 100644
--- a/gi/__init__.py
+++ b/gi/__init__.py
@@ -26,6 +26,7 @@ __path__ = extend_path(__path__, __name__)
import sys
import os
+import importlib
# we can't have pygobject 2 loaded at the same time we load the internal _gobject
if 'gobject' in sys.modules:
@@ -33,6 +34,7 @@ if 'gobject' in sys.modules:
'modules like "gobject". Please change all occurrences '
'of "import gobject" to "from gi.repository import GObject".')
+from . import _gi
from ._gi import _gobject
from ._gi import _API
from ._gi import Repository
@@ -87,3 +89,29 @@ def require_version(namespace, version):
def get_required_version(namespace):
return _versions.get(namespace, None)
+
+
+def require_foreign(namespace, symbol=None):
+ """Ensure the given foreign marshaling module is available and loaded.
+
+ :param str namespace:
+ Introspection namespace of the foreign module (e.g. "cairo")
+ :param symbol:
+ Optional symbol typename to ensure a converter exists.
+ :type symbol: str or None
+ :raises: ImportError
+
+ :Example:
+
+ .. code-block:: python
+
+ import gi
+ import cairo
+ gi.require_foreign('cairo')
+
+ """
+ try:
+ _gi.require_foreign(namespace, symbol)
+ except Exception as e:
+ raise ImportError(str(e))
+ importlib.import_module('gi.repository', namespace)