summaryrefslogtreecommitdiff
path: root/gi/__init__.py
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2017-07-12 08:35:52 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2017-07-12 08:35:52 +0900
commitc79482ebfe55da780fd2d733696f5107dc4d5cb8 (patch)
tree8411f3b719fb7caa88160b97cf5f00802a717cec /gi/__init__.py
parentee96b8b4ed303ec374e37237f86555754cf2ae60 (diff)
downloadpygobject2-c79482ebfe55da780fd2d733696f5107dc4d5cb8.tar.gz
pygobject2-c79482ebfe55da780fd2d733696f5107dc4d5cb8.tar.bz2
pygobject2-c79482ebfe55da780fd2d733696f5107dc4d5cb8.zip
Imported Upstream version 2.27.91
Change-Id: I3788dba2f5257cabaed71dd66932f46025d61a4e Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'gi/__init__.py')
-rw-r--r--gi/__init__.py29
1 files changed, 28 insertions, 1 deletions
diff --git a/gi/__init__.py b/gi/__init__.py
index fb711c3..ed20606 100644
--- a/gi/__init__.py
+++ b/gi/__init__.py
@@ -20,8 +20,35 @@
from __future__ import absolute_import
-from ._gi import _API
+from ._gi import _API, Repository
# Force loading the GObject typelib so we have available the wrappers for
# base classes such as GInitiallyUnowned
from gi.repository import GObject
+
+_versions = {}
+
+def require_version(namespace, version):
+ repository = Repository.get_default()
+
+ if namespace in repository.get_loaded_namespaces():
+ if repository.get_version(namespace) != version:
+ raise ValueError('Namespace %s is already loaded with version %s' % \
+ (namespace, loaded_version))
+
+ if namespace in _versions and _versions[namespace] != version:
+ raise ValueError('Namespace %s already requires version %s' % \
+ (namespace, _versions[namespace]))
+
+ available_versions = repository.enumerate_versions(namespace)
+ if not available_versions:
+ raise ValueError('Namespace %s not available' % namespace)
+
+ if version not in available_versions:
+ raise ValueError('Namespace %s not available for version %s' % \
+ (namespace, version))
+
+ _versions[namespace] = version
+
+def get_required_version(namespace):
+ return _versions.get(namespace, None)