Extend the internal libguestfsmod module with the CREATE values, so
there is no need to hardcode values in GuestFS.__init__.
---
generator/python.ml | 7 +++++--
python/guestfs-py-byhand.c | 7 +++++++
python/guestfs-py.h | 2 ++
3 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/generator/python.ml b/generator/python.ml
index 9744b8f..470abe7 100644
--- a/generator/python.ml
+++ b/generator/python.ml
@@ -597,6 +597,9 @@ moduleinit (void)
m = Py_InitModule ((char *) \"libguestfsmod\", methods);
#endif
+ if (m != NULL)
+ guestfs_int_py_extend_module (m);
+
return m; /* m might be NULL if module init failed */
}
@@ -719,9 +722,9 @@ class GuestFS(object):
\"\"\"
flags = 0
if not environment:
- flags |= 1
+ flags |= libguestfsmod.GUESTFS_CREATE_NO_ENVIRONMENT
if not close_on_exit:
- flags |= 2
+ flags |= libguestfsmod.GUESTFS_CREATE_NO_CLOSE_ON_EXIT
self._o = libguestfsmod.create(flags)
self._python_return_dict = python_return_dict
diff --git a/python/guestfs-py-byhand.c b/python/guestfs-py-byhand.c
index cf8576f..9e2debf 100644
--- a/python/guestfs-py-byhand.c
+++ b/python/guestfs-py-byhand.c
@@ -37,6 +37,13 @@
static PyObject **get_all_event_callbacks (guestfs_h *g, size_t *len_rtn);
+void
+guestfs_int_py_extend_module (PyObject *module)
+{
+ PyModule_AddIntMacro(module, GUESTFS_CREATE_NO_ENVIRONMENT);
+ PyModule_AddIntMacro(module, GUESTFS_CREATE_NO_CLOSE_ON_EXIT);
+}
+
PyObject *
guestfs_int_py_create (PyObject *self, PyObject *args)
{
diff --git a/python/guestfs-py.h b/python/guestfs-py.h
index da5f483..f2246a6 100644
--- a/python/guestfs-py.h
+++ b/python/guestfs-py.h
@@ -59,6 +59,8 @@ put_handle (guestfs_h *g)
#endif
}
+extern void guestfs_int_py_extend_module (PyObject *module);
+
extern PyObject *guestfs_int_py_create (PyObject *self, PyObject *args);
extern PyObject *guestfs_int_py_close (PyObject *self, PyObject *args);
extern PyObject *guestfs_int_py_set_event_callback (PyObject *self, PyObject *args);
--
2.5.5