Introspection: add col/row manipulations
[gnumeric.git] / test / t3002-introspection-io.py
blob93edc9b14b72496e20b88958e774f6247b543ec1
1 #!/usr/bin/python
2 # -----------------------------------------------------------------------------
4 import gi
5 gi.require_version('Gnm', '1.12')
6 gi.require_version('GOffice', '0.10')
7 from gi.repository import Gnm
8 from gi.repository import GOffice
9 Gnm.init()
11 import sys
12 src_uri = GOffice.filename_to_uri (sys.argv[1])
13 dst_uri = GOffice.filename_to_uri (sys.argv[2])
15 # A context for reporting errors to stderr
16 cc = Gnm.CmdContextStderr.new()
18 # Load plugins
19 Gnm.plugins_init(cc)
21 # A context for io operations
22 ioc = GOffice.IOContext.new (cc)
24 # Read a file
25 wbv = Gnm.WorkbookView.new_from_uri (src_uri, None, ioc, None)
26 wb = wbv.props.workbook
27 print("Loaded {}".format(wb.props.uri))
29 # Save a file
30 fs = GOffice.FileSaver.for_file_name (dst_uri)
31 if wbv.save_as (fs, dst_uri, cc):
32 print("Saved {}".format(wb.props.uri))
33 else:
34 print("Failed to save to {}".format(dst_uri))
37 # Remove our references to the objects
38 wb = None
39 wbv = None
40 ioc = None
41 wbv = None