1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 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)
|