pybank r64 - in trunk: . bank
- From: walters svn gnome org
- To: svn-commits-list gnome org
- Subject: pybank r64 - in trunk: . bank
- Date: Wed, 20 Aug 2008 23:59:44 +0000 (UTC)
Author: walters
Date: Wed Aug 20 23:59:44 2008
New Revision: 64
URL: http://svn.gnome.org/viewvc/pybank?rev=64&view=rev
Log:
2008-08-20 Colin Walters <walters verbum org>
* bank/bank-repository.c: Bind new
g_irepository_require.
* bank/repository.py: Another layer for same.
* bank/importer.py: Try to look up names
in GIRepository using built-in logic rather
than duplicating it here.
* bank/module.py: Don't call .register.
Modified:
trunk/ChangeLog
trunk/bank/bank-repository.c
trunk/bank/importer.py
trunk/bank/module.py
trunk/bank/repository.py
Modified: trunk/bank/bank-repository.c
==============================================================================
--- trunk/bank/bank-repository.c (original)
+++ trunk/bank/bank-repository.c Wed Aug 20 23:59:44 2008
@@ -46,21 +46,21 @@
};
static PyObject *
-_wrap_g_irepository_register_filename(PyGIRepository *self,
- PyObject *args,
- PyObject *kwargs)
+_wrap_g_irepository_require(PyGIRepository *self,
+ PyObject *args,
+ PyObject *kwargs)
{
- static char *kwlist[] = { "filename", NULL };
+ static char *kwlist[] = { "namespace", NULL };
gchar *filename;
const gchar *namespace;
GError *error = NULL;
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
- "s:GIRepository.register_filename",
+ "s:GIRepository.require",
kwlist, &filename))
return NULL;
- namespace = g_irepository_register_file (self->repo, filename, &error);
+ namespace = g_irepository_require (self->repo, filename, &error);
if (error) {
g_print ("ERROR: %s (FIXME: raise GError exception)\n",
@@ -177,7 +177,7 @@
}
static PyMethodDef _PyGIRepository_methods[] = {
- { "register_filename", (PyCFunction)_wrap_g_irepository_register_filename, METH_VARARGS|METH_KEYWORDS },
+ { "require", (PyCFunction)_wrap_g_irepository_require, METH_VARARGS|METH_KEYWORDS },
{ "getNamespaces", (PyCFunction)_wrap_g_irepository_get_namespaces, METH_NOARGS },
{ "getInfos", (PyCFunction)_wrap_g_irepository_get_infos, METH_VARARGS|METH_KEYWORDS },
{ "getDefault", (PyCFunction)_wrap_g_irepository_get_default, METH_STATIC|METH_NOARGS },
Modified: trunk/bank/importer.py
==============================================================================
--- trunk/bank/importer.py (original)
+++ trunk/bank/importer.py Wed Aug 20 23:59:44 2008
@@ -20,18 +20,18 @@
import os
import sys
+from .repository import repository
+
class DynamicImporter(object):
def __init__(self, name, path):
self.name = name
self.path = path
@staticmethod
- def find_module(name, path):
- for path in os.environ.get("XDG_DATA_DIRS", "/usr/share").split(":"):
- full = os.path.join(path, 'gitypelibs')
- filename = os.path.join(full, name + '.typelib')
- if os.path.exists(filename):
- return DynamicImporter(name, filename)
+ def find_module(name, path=None):
+ namespace = repository.require(name)
+ if namespace:
+ return DynamicImporter(name, path)
def load_module(self, name):
from .module import DynamicModule
Modified: trunk/bank/module.py
==============================================================================
--- trunk/bank/module.py (original)
+++ trunk/bank/module.py Wed Aug 20 23:59:44 2008
@@ -25,15 +25,14 @@
from .repository import repository
class DynamicModule(object):
- def __init__(self, namespace, repo_path):
+ def __init__(self, namespace, path):
self._namespace = namespace
- self._repo_path = repo_path
- repository.register(self, namespace, repo_path)
+ self._path = path
self.created()
@property
def __file__(self):
- return os.path.abspath(self._repo_path)
+ return self._namespace
@property
def __name__(self):
Modified: trunk/bank/repository.py
==============================================================================
--- trunk/bank/repository.py (original)
+++ trunk/bank/repository.py Wed Aug 20 23:59:44 2008
@@ -33,6 +33,9 @@
#assert loaded_namespace == namespace
self._modules[namespace] = module
+ def require(self, namespace):
+ return self._repo.require(namespace)
+
def get_module(self, namespace):
return self._modules.get(namespace)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]