[libgsf] Introspection: add test-cp-msole.py sample



commit 7f32da6dffc64b17edeec086784a2fb53875205c
Author: Morten Welinder <terra gnome org>
Date:   Sun Feb 24 19:39:30 2013 -0500

    Introspection: add test-cp-msole.py sample

 configure.ac            |    1 +
 python/Makefile.am      |    1 +
 python/test-cp-msole.py |   53 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 55 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 566ab1d..abc7cd6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -467,6 +467,7 @@ m4/Makefile
 doc/Makefile
 gsf/Makefile
 gsf-win32/Makefile
+python/Makefile
 tests/Makefile
 tools/Makefile
 thumbnailer/Makefile
diff --git a/python/Makefile.am b/python/Makefile.am
new file mode 100644
index 0000000..622eba1
--- /dev/null
+++ b/python/Makefile.am
@@ -0,0 +1 @@
+EXTRA_DIST = test-cp-msole.py
diff --git a/python/test-cp-msole.py b/python/test-cp-msole.py
new file mode 100755
index 0000000..a7e1eec
--- /dev/null
+++ b/python/test-cp-msole.py
@@ -0,0 +1,53 @@
+#!/usr/bin/python
+#
+# test-cp-msole.py
+#
+
+import sys
+from gi.repository import Gsf
+
+def clone(iput, oput):
+    size = iput.size
+    if size > 0:
+        lr = iput.remaining()
+        while lr > 0:
+            data = iput.read(lr)
+            ld = len(data)
+            lr = lr - ld
+            oput.write(data)
+    else:
+        clone_dir(iput, oput)
+    oput.close()
+
+def clone_dir(iput, oput):
+    nc = iput.num_children()
+    for i in range(nc):
+        inew = iput.child_by_index(i)
+        isdir = inew.num_children() > 0
+        onew = oput.new_child(iput.name_by_index(i), isdir)
+        clone(inew, onew)
+
+def test(argv):
+    print "test", argv[1], argv[2]
+
+    input = Gsf.InputStdio.new(argv[1])
+    if input == None:
+        print "yuck1"
+    infile = Gsf.InfileMSOle.new(input)
+    if infile == None:
+        print "yuck2"
+    del input
+
+    output = Gsf.OutputStdio.new(argv[2])
+    if output == None:
+        print "yuck3"
+    outfile = Gsf.OutfileMSOle.new(output)
+    if outfile == None:
+        print "yuck4"
+    del output
+
+    clone(infile, outfile)
+
+
+
+test(sys.argv)


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