pygobject r923 - in trunk: . gio tests
- From: gianmt svn gnome org
- To: svn-commits-list gnome org
- Subject: pygobject r923 - in trunk: . gio tests
- Date: Sun, 3 Aug 2008 20:11:13 +0000 (UTC)
Author: gianmt
Date: Sun Aug 3 20:11:13 2008
New Revision: 923
URL: http://svn.gnome.org/viewvc/pygobject?rev=923&view=rev
Log:
Wrap GFile.replace_async and query_info_async with docs and test.
Modified:
trunk/ChangeLog
trunk/gio/gfile.override
trunk/gio/gio.defs
trunk/tests/test_gio.py
Modified: trunk/gio/gfile.override
==============================================================================
--- trunk/gio/gfile.override (original)
+++ trunk/gio/gfile.override Sun Aug 3 20:11:13 2008
@@ -869,11 +869,104 @@
Py_INCREF(Py_None);
return Py_None;
}
+%%
+override g_file_replace_async kwargs
+static PyObject *
+_wrap_g_file_replace_async(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "callback", "etag", "make_backup", "flags",
+ "io_priority", "cancellable", "user_data", NULL };
+ GCancellable *cancellable;
+ PyGObject *pycancellable = NULL;
+ GFileCreateFlags flags = G_FILE_CREATE_NONE;
+ PyObject *py_flags = NULL;
+ int io_priority = G_PRIORITY_DEFAULT;
+ char *etag = NULL;
+ gboolean make_backup = TRUE;
+ PyObject *py_backup = Py_True;
+ PyGIONotify *notify;
+ notify = g_slice_new0(PyGIONotify);
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O|zOOiOO:File.replace_async",
+ kwlist,
+ ¬ify->callback,
+ &etag, &py_backup,
+ &flags, &io_priority,
+ &pycancellable,
+ ¬ify->data))
+
+ {
+ g_slice_free(PyGIONotify, notify);
+ return NULL;
+ }
+
+ make_backup = PyObject_IsTrue(py_backup) ? TRUE : FALSE;
+
+ if (py_flags && pyg_flags_get_value(G_TYPE_FILE_CREATE_FLAGS,
+ py_flags, (gpointer)&flags))
+ return NULL;
+
+ if (!pygio_check_cancellable(pycancellable, &cancellable))
+ return NULL;
+
+ g_file_replace_async(G_FILE(self->obj), etag, make_backup, flags,
+ io_priority, cancellable,
+ (GAsyncReadyCallback)async_result_callback_marshal,
+ notify);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+%%
+override g_file_query_info_async kwargs
+static PyObject *
+_wrap_g_file_query_info_async(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "callback", "attributes", "flags",
+ "io_priority", "cancellable", "user_data", NULL };
+ GCancellable *cancellable;
+ PyGObject *pycancellable = NULL;
+ GFileQueryInfoFlags flags = G_FILE_QUERY_INFO_NONE;
+ PyObject *py_flags = NULL;
+ int io_priority = G_PRIORITY_DEFAULT;
+ char *attributes;
+ PyGIONotify *notify;
+
+ notify = g_slice_new0(PyGIONotify);
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "Os|OiOO:File.query_info_async",
+ kwlist,
+ ¬ify->callback,
+ &attributes,
+ &flags, &io_priority,
+ &pycancellable,
+ ¬ify->data))
+
+ {
+ g_slice_free(PyGIONotify, notify);
+ return NULL;
+ }
+
+ if (py_flags && pyg_flags_get_value(G_TYPE_FILE_CREATE_FLAGS,
+ py_flags, (gpointer)&flags))
+ return NULL;
+
+ if (!pygio_check_cancellable(pycancellable, &cancellable))
+ return NULL;
+
+ g_file_query_info_async(G_FILE(self->obj), attributes, flags,
+ io_priority, cancellable,
+ (GAsyncReadyCallback)async_result_callback_marshal,
+ notify);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
/* GFile.eject_mountable */
/* GFile.find_enclosing_mount_async */
-/* GFile.query_info_async */
-/* GFile.replace_async */
/* GFile.replace_contents_async */
/* GFile.set_attributes_async */
/* GFile.set_display_name_async */
Modified: trunk/gio/gio.defs
==============================================================================
--- trunk/gio/gio.defs (original)
+++ trunk/gio/gio.defs Sun Aug 3 20:11:13 2008
@@ -1453,6 +1453,16 @@
)
(define-method replace_async
+ (docstring
+ "F.replace_async(callback [etag, [make_backup, [flags, [io_priority, [cancellable, [user_data]]]]]]) -> file replace\n"
+ "\n"
+ "Asynchronously overwrites the file, replacing the contents, possibly\n"
+ "creating a backup copy of the file first.\n"
+ "For more details, see F.replace() which is the synchronous\n"
+ "version of this call.\n"
+ "When the operation is finished, callback will be called. You can\n"
+ "then call F.replace_finish() to get the result of the operation."
+ )
(of-object "GFile")
(c-name "g_file_replace_async")
(return-type "none")
@@ -1499,6 +1509,16 @@
)
(define-method query_info_async
+ (docstring
+ "F.query_info_async(callback, attributes, [flags, [io_priority, [cancellable, [user_data]]]]) -> query attributes\n\n"
+ "Asynchronously gets the requested information about specified file.\n"
+ "The result is a GFileInfo object that contains key-value attributes\n"
+ "(such as type or size for the file).\n"
+ "For more details, see F.query_info() which is the synchronous\n"
+ "version of this call. \n"
+ "When the operation is finished, callback will be called. You can\n"
+ "then call F.query_info_finish() to get the result of the operation.\n"
+ )
(of-object "GFile")
(c-name "g_file_query_info_async")
(return-type "none")
Modified: trunk/tests/test_gio.py
==============================================================================
--- trunk/tests/test_gio.py (original)
+++ trunk/tests/test_gio.py Sun Aug 3 20:11:13 2008
@@ -111,6 +111,49 @@
loop = glib.MainLoop()
loop.run()
+ def testReplaceAsync(self):
+ self._f.write("testing")
+ self._f.close()
+
+ def callback(file, result):
+ try:
+ stream = file.replace_finish(result)
+ self.failUnless(isinstance(stream, gio.OutputStream))
+ stream.write("some new string")
+ stream.close()
+ cont, leng, etag = file.load_contents()
+ self.assertEqual(cont, "some new string")
+ finally:
+ loop.quit()
+
+
+ self.file.replace_async(callback, None, True, gio.FILE_CREATE_NONE,
+ glib.PRIORITY_HIGH)
+
+ loop = glib.MainLoop()
+ loop.run()
+
+ def testReplaceAsyncNoargs(self):
+ self._f.write("testing")
+ self._f.close()
+
+ def callback(file, result):
+ try:
+ stream = file.replace_finish(result)
+ self.failUnless(isinstance(stream, gio.OutputStream))
+ stream.write("some new string")
+ stream.close()
+ cont, leng, etag = file.load_contents()
+ self.assertEqual(cont, "some new string")
+ finally:
+ loop.quit()
+
+
+ self.file.replace_async(callback)
+
+ loop = glib.MainLoop()
+ loop.run()
+
def testReadAsyncError(self):
self.assertRaises(TypeError, self.file.read_async)
self.assertRaises(TypeError, self.file.read_async, "foo", "bar")
@@ -169,6 +212,20 @@
loop = glib.MainLoop()
loop.run()
+ def testQueryInfoAsync(self):
+ def callback(file, result):
+ try:
+ info = file.query_info_finish(result)
+ self.failUnless(isinstance(info, gio.FileInfo))
+ self.failUnless(info.get_name(), "file.txt")
+ finally:
+ loop.quit()
+
+ self.file.query_info_async(callback, "standard")
+
+ loop = glib.MainLoop()
+ loop.run()
+
def testMountMountable(self):
gfile = gio.File('localtest:')
def unmount_done(mount, result):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]