GNOME Bugzilla – Bug 461847
python_loader plugin passes input and output objects as gobjects to python
Last modified: 2018-05-22 13:21:59 UTC
There is no way to do anything with generic gobject objects in python, so you can't do any reading/writing in a python plugin. It used to be passing filenames, but now someone fixed it. Fixing it to pass filenames would work, though i guess adding a pythonic wrapper for GfsOutput and GfsInput would be the right way.
We can't use filenames anymore since input sources might not have filenames. But it sounds like a GsfInput/GsfOutput would be a better choice. And that would match how methods are called.
It seems that GsfOutput and GsfInput objects are not a part of gnumeric. So I am wondering whether having the API in gnumeric code instead libgsf is workable?
There are python bindings for libgsf as well, and as of libgsf 1.14.2, they are built by default. If your distribution has them, you can do e.g. import gsf output.write(len(str), str) or t=gsf.InputTextline(input) # Read input line by line while 1: s = t.utf8_gets() if not s: break print s I'm attaching .py and plugin.xml for a plugin which reads and saves /etc/passwd style files.
Created attachment 95225 [details] plugin.xml
Created attachment 95226 [details] Python code for a file i/o plugin
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gnumeric/issues/79.