pygobject r909 - in trunk: . gio tests



Author: gianmt
Date: Fri Aug  1 22:42:37 2008
New Revision: 909
URL: http://svn.gnome.org/viewvc/pygobject?rev=909&view=rev

Log:
Wrap GFile.query_writable_namespaces 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	Fri Aug  1 22:42:37 2008
@@ -737,7 +737,52 @@
         return Py_None;
     }
 }
+%%
+override g_file_query_writable_namespaces kwargs
+static PyObject *
+_wrap_g_file_query_writable_namespaces(PyGObject *self,
+                                       PyObject *args,
+                                       PyObject *kwargs)
+{
+    static char *kwlist[] = { "cancellable", NULL };
+    PyGObject *pycancellable = NULL;
+    GCancellable *cancellable = NULL;
+    GFileAttributeInfoList *ret;
+    GError *error = NULL;
+    gint i, n_infos;
+    GFileAttributeInfo *infos;
+    PyObject *py_ret;
 
+    if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+                                     "|O:GFile.query_writable_namespaces",
+                                     kwlist, &pycancellable))
+        return NULL;
+
+    if (!pygio_check_cancellable(pycancellable, &cancellable))
+        return NULL;
+
+    ret = g_file_query_writable_namespaces(G_FILE(self->obj),
+                                           (GCancellable *) cancellable,
+                                           &error);
+    if (pyg_error_check(&error))
+        return NULL;
+
+    n_infos = ret->n_infos;
+    infos = ret->infos;
+
+    if (n_infos > 0) {
+        py_ret = PyList_New(n_infos);
+        for (i = 0; i < n_infos; i++) {
+            PyList_SetItem(py_ret, i, pyg_file_attribute_info_new(&infos[i]));
+        }
+        g_file_attribute_info_list_unref(ret);
+        return py_ret;
+
+    } else {
+        Py_INCREF(Py_None);
+        return Py_None;
+    }
+}
 /* GFile.append_to_async */
 /* GFile.create_async */
 /* GFile.eject_mountable */
@@ -749,7 +794,6 @@
 /* GFile.set_display_name_async */
 /* GFile.load_partial_contents_async: No ArgType for GFileReadMoreCallback */
 /* GFile.move: No ArgType for GFileProgressCallback */
-/* GFile.query_writable_namespaces: No ArgType for GFileAttributeInfoList* */
 /* GFile.set_attributes_finish: No ArgType for GFileInfo** */
 /* GFile.load_partial_contents_finish: No ArgType for char** */
 /* GFile.replace_contents: No ArgType for char** */

Modified: trunk/gio/gio.defs
==============================================================================
--- trunk/gio/gio.defs	(original)
+++ trunk/gio/gio.defs	Fri Aug  1 22:42:37 2008
@@ -1818,6 +1818,16 @@
 )
 
 (define-method query_writable_namespaces
+  (docstring
+  "F.query_writable_namespaces([cancellable]) -> list\n\n"
+  "Obtain the list of attribute namespaces where new attributes can\n"
+  "be created by a user. An example of this is extended attributes\n"
+  "(in the "xattr" namespace).\n"
+  "If cancellable is not None, then the operation can be cancelled\n"
+  "by triggering the cancellable object from another thread. If the\n"
+  "operation was cancelled, the error gio.IO_ERROR_CANCELLED\n"
+  "will be returned."
+  )
   (of-object "GFile")
   (c-name "g_file_query_writable_namespaces")
   (return-type "GFileAttributeInfoList*")

Modified: trunk/tests/test_gio.py
==============================================================================
--- trunk/tests/test_gio.py	(original)
+++ trunk/tests/test_gio.py	Fri Aug  1 22:42:37 2008
@@ -196,6 +196,12 @@
                 self.assertEqual(info.flags,
                                  gio.FILE_ATTRIBUTE_INFO_COPY_WHEN_MOVED)
 
+    def testQueryWritableNamespaces(self):
+        infolist = self.file.query_writable_namespaces()
+        for info in infolist:
+            if info.name == "xattr":
+                self.assertEqual(info.type, gio.FILE_ATTRIBUTE_TYPE_STRING)
+
     def testSetAttribute(self):
         self._f.write("testing attributes")
         self._f.seek(0)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]