pygobject r771 - in trunk: . gio tests



Author: johan
Date: Tue Apr  8 21:09:56 2008
New Revision: 771
URL: http://svn.gnome.org/viewvc/pygobject?rev=771&view=rev

Log:
2008-04-08  Johan Dahlin  <jdahlin async com br>

    * gio/Makefile.am:
    * gio/gfileinfo.override:
    * gio/gio.defs:
    * gio/gio.override:
    * tests/test_gio.py:
    Wrap GFileInfo.list_attributes(), add tests and
    set the default of GFileQueryInfoFlags args to G_FILE_QUERY_INFO_NONE.



Added:
   trunk/gio/gfileinfo.override
Modified:
   trunk/ChangeLog
   trunk/gio/Makefile.am
   trunk/gio/gio.defs
   trunk/gio/gio.override
   trunk/tests/test_gio.py

Modified: trunk/gio/Makefile.am
==============================================================================
--- trunk/gio/Makefile.am	(original)
+++ trunk/gio/Makefile.am	Tue Apr  8 21:09:56 2008
@@ -37,6 +37,7 @@
 	gio.override			\
 	gfile.override			\
 	gfileenumerator.override	\
+	gfileinfo.override		\
 	ginputstream.override 		\
 	goutputstream.override 		\
 	gvolumemonitor.override

Added: trunk/gio/gfileinfo.override
==============================================================================
--- (empty file)
+++ trunk/gio/gfileinfo.override	Tue Apr  8 21:09:56 2008
@@ -0,0 +1,52 @@
+/* -*- Mode: C; c-basic-offset: 4 -*-
+ * pygobject - Python bindings for GObject
+ * Copyright (C) 2008  Johan Dahlin
+ *
+ *   gfile.override: module overrides for GInputStream
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ */
+%%
+override g_file_info_list_attributes kwargs
+static PyObject *
+_wrap_g_file_info_list_attributes(PyGObject *self, 
+                                  PyObject  *args, 
+				  PyObject  *kwargs)
+{
+    char *kwlist[] = { "name_space", NULL};
+    gchar *name_space;
+    gchar **names;
+    PyObject *ret;
+    
+    if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+				     "s:gio.FileInfo.list_attributes",
+				     kwlist, &name_space))
+	return NULL;
+
+    names = g_file_info_list_attributes(G_FILE_INFO(self->obj),
+					name_space);
+
+    ret = PyList_New(0);
+    while (names && *names) {
+        PyObject *item = PyString_FromString(names[0]);
+        PyList_Append(ret, item);
+        Py_DECREF(item);
+
+        names++;
+    }
+
+    return ret;
+}

Modified: trunk/gio/gio.defs
==============================================================================
--- trunk/gio/gio.defs	(original)
+++ trunk/gio/gio.defs	Tue Apr  8 21:09:56 2008
@@ -1398,7 +1398,7 @@
   (return-type "GFileInfo*")
   (parameters
     '("const-char*" "attributes")
-    '("GFileQueryInfoFlags" "flags")
+    '("GFileQueryInfoFlags" "flags" (default "G_FILE_QUERY_INFO_NONE"))
     '("GCancellable*" "cancellable" (null-ok) (default "NULL"))
     '("GError**" "error")
   )
@@ -1410,7 +1410,7 @@
   (return-type "none")
   (parameters
     '("const-char*" "attributes")
-    '("GFileQueryInfoFlags" "flags")
+    '("GFileQueryInfoFlags" "flags" (default "G_FILE_QUERY_INFO_NONE"))
     '("int" "io_priority")
     '("GCancellable*" "cancellable" (null-ok) (default "NULL"))
     '("GAsyncReadyCallback" "callback")
@@ -1477,7 +1477,7 @@
   (return-type "GFileEnumerator*")
   (parameters
     '("const-char*" "attributes")
-    '("GFileQueryInfoFlags" "flags")
+    '("GFileQueryInfoFlags" "flags" (default "G_FILE_QUERY_INFO_NONE"))
     '("GCancellable*" "cancellable" (null-ok) (default "NULL"))
     '("GError**" "error")
   )
@@ -1489,7 +1489,7 @@
   (return-type "none")
   (parameters
     '("const-char*" "attributes")
-    '("GFileQueryInfoFlags" "flags")
+    '("GFileQueryInfoFlags" "flags" (default "G_FILE_QUERY_INFO_NONE"))
     '("int" "io_priority")
     '("GCancellable*" "cancellable" (null-ok) (default "NULL"))
     '("GAsyncReadyCallback" "callback")
@@ -1638,7 +1638,7 @@
     '("const-char*" "attribute")
     '("GFileAttributeType" "type")
     '("gpointer" "value_p")
-    '("GFileQueryInfoFlags" "flags")
+    '("GFileQueryInfoFlags" "flags" (default "G_FILE_QUERY_INFO_NONE"))
     '("GCancellable*" "cancellable" (null-ok) (default "NULL"))
     '("GError**" "error")
   )
@@ -1650,7 +1650,7 @@
   (return-type "gboolean")
   (parameters
     '("GFileInfo*" "info")
-    '("GFileQueryInfoFlags" "flags")
+    '("GFileQueryInfoFlags" "flags" (default "G_FILE_QUERY_INFO_NONE"))
     '("GCancellable*" "cancellable" (null-ok) (default "NULL"))
     '("GError**" "error")
   )
@@ -1662,7 +1662,7 @@
   (return-type "none")
   (parameters
     '("GFileInfo*" "info")
-    '("GFileQueryInfoFlags" "flags")
+    '("GFileQueryInfoFlags" "flags" (default "G_FILE_QUERY_INFO_NONE"))
     '("int" "io_priority")
     '("GCancellable*" "cancellable" (null-ok) (default "NULL"))
     '("GAsyncReadyCallback" "callback")
@@ -1688,7 +1688,7 @@
   (parameters
     '("const-char*" "attribute")
     '("const-char*" "value")
-    '("GFileQueryInfoFlags" "flags")
+    '("GFileQueryInfoFlags" "flags" (default "G_FILE_QUERY_INFO_NONE"))
     '("GCancellable*" "cancellable" (null-ok) (default "NULL"))
     '("GError**" "error")
   )
@@ -1701,7 +1701,7 @@
   (parameters
     '("const-char*" "attribute")
     '("const-char*" "value")
-    '("GFileQueryInfoFlags" "flags")
+    '("GFileQueryInfoFlags" "flags" (default "G_FILE_QUERY_INFO_NONE"))
     '("GCancellable*" "cancellable" (null-ok) (default "NULL"))
     '("GError**" "error")
   )
@@ -1714,7 +1714,7 @@
   (parameters
     '("const-char*" "attribute")
     '("guint32" "value")
-    '("GFileQueryInfoFlags" "flags")
+    '("GFileQueryInfoFlags" "flags" (default "G_FILE_QUERY_INFO_NONE"))
     '("GCancellable*" "cancellable" (null-ok) (default "NULL"))
     '("GError**" "error")
   )
@@ -1727,7 +1727,7 @@
   (parameters
     '("const-char*" "attribute")
     '("gint32" "value")
-    '("GFileQueryInfoFlags" "flags")
+    '("GFileQueryInfoFlags" "flags" (default "G_FILE_QUERY_INFO_NONE"))
     '("GCancellable*" "cancellable" (null-ok) (default "NULL"))
     '("GError**" "error")
   )
@@ -1740,7 +1740,7 @@
   (parameters
     '("const-char*" "attribute")
     '("guint64" "value")
-    '("GFileQueryInfoFlags" "flags")
+    '("GFileQueryInfoFlags" "flags" (default "G_FILE_QUERY_INFO_NONE"))
     '("GCancellable*" "cancellable" (null-ok) (default "NULL"))
     '("GError**" "error")
   )
@@ -1753,7 +1753,7 @@
   (parameters
     '("const-char*" "attribute")
     '("gint64" "value")
-    '("GFileQueryInfoFlags" "flags")
+    '("GFileQueryInfoFlags" "flags" (default "G_FILE_QUERY_INFO_NONE"))
     '("GCancellable*" "cancellable" (null-ok) (default "NULL"))
     '("GError**" "error")
   )

Modified: trunk/gio/gio.override
==============================================================================
--- trunk/gio/gio.override	(original)
+++ trunk/gio/gio.override	Tue Apr  8 21:09:56 2008
@@ -80,6 +80,7 @@
 include
   gfile.override
   gfileenumerator.override
+  gfileinfo.override
   ginputstream.override
   goutputstream.override
   gvolumemonitor.override

Modified: trunk/tests/test_gio.py
==============================================================================
--- trunk/tests/test_gio.py	(original)
+++ trunk/tests/test_gio.py	Tue Apr  8 21:09:56 2008
@@ -229,3 +229,12 @@
             data='<html></html>', want_uncertain=True)
         self.assertEquals('text/html', mime_type)
         self.assertEquals(bool, type(result_uncertain))
+
+
+class TestFileInfo(unittest.TestCase):
+    def testListAttributes(self):
+        gfile = gio.File("test_gio.py")
+        fileinfo = gfile.query_info("*")
+        attributes = fileinfo.list_attributes("standard")
+        self.failUnless(attributes)
+        self.failUnless('standard::name' in attributes)



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