pygobject r912 - in trunk: . gio tests
- From: gianmt svn gnome org
- To: svn-commits-list gnome org
- Subject: pygobject r912 - in trunk: . gio tests
- Date: Sat, 2 Aug 2008 08:25:25 +0000 (UTC)
Author: gianmt
Date: Sat Aug 2 08:25:25 2008
New Revision: 912
URL: http://svn.gnome.org/viewvc/pygobject?rev=912&view=rev
Log:
Wrap GFile.append_to_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 Sat Aug 2 08:25:25 2008
@@ -783,7 +783,50 @@
return Py_None;
}
}
-/* GFile.append_to_async */
+%%
+override g_file_append_to_async kwargs
+static PyObject *
+_wrap_g_file_append_to_async(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "callback", "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;
+ PyGIONotify *notify;
+
+ notify = g_slice_new0(PyGIONotify);
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O|OiOO:File.append_to_async",
+ kwlist,
+ ¬ify->callback,
+ &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_append_to_async(G_FILE(self->obj), flags, io_priority, cancellable,
+ (GAsyncReadyCallback)async_result_callback_marshal,
+ notify);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
/* GFile.create_async */
/* GFile.eject_mountable */
/* GFile.find_enclosing_mount_async */
Modified: trunk/gio/gio.defs
==============================================================================
--- trunk/gio/gio.defs (original)
+++ trunk/gio/gio.defs Sat Aug 2 08:25:25 2008
@@ -1389,6 +1389,15 @@
)
(define-method append_to_async
+ (docstring
+ "F.append_to_async(callback [flags, [,io_priority [,cancellable [,user_data]]]]) -> open for append\n"
+ "\n"
+ "Asynchronously opens file for appending."
+ "For more details, see gio.File.append_to() which is the synchronous\n"
+ "version of this call. When the operation is finished, callback will\n"
+ "be called. You can then call F.append_to_finish() to get the result\n"
+ "of the operation."
+ )
(of-object "GFile")
(c-name "g_file_append_to_async")
(return-type "none")
Modified: trunk/tests/test_gio.py
==============================================================================
--- trunk/tests/test_gio.py (original)
+++ trunk/tests/test_gio.py Sat Aug 2 08:25:25 2008
@@ -33,6 +33,45 @@
loop = glib.MainLoop()
loop.run()
+ def testAppendToAsync(self):
+ self._f.write("append_to ")
+ self._f.close()
+
+ def callback(file, result):
+ try:
+ stream = file.append_to_finish(result)
+ self.failUnless(isinstance(stream, gio.OutputStream))
+ w = stream.write("testing")
+ cont, leng, etag = self.file.load_contents()
+ self.assertEqual(cont, "append_to testing")
+ finally:
+ loop.quit()
+
+ self.file.append_to_async(callback, gio.FILE_CREATE_NONE,
+ glib.PRIORITY_HIGH)
+
+ loop = glib.MainLoop()
+ loop.run()
+
+ def testAppendToAsyncNoargs(self):
+ self._f.write("append_to ")
+ self._f.close()
+
+ def callback(file, result):
+ try:
+ stream = file.append_to_finish(result)
+ self.failUnless(isinstance(stream, gio.OutputStream))
+ w = stream.write("testing")
+ cont, leng, etag = self.file.load_contents()
+ self.assertEqual(cont, "append_to testing")
+ finally:
+ loop.quit()
+
+ self.file.append_to_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")
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]