Re: Provide a python script to dia on the command line



Hi Martin,
Am 11.09.2014 um 12:55 schrieb Martin Metzker:
[...]
I can "dia -i foo.py" to make dia execute foo.py. The script is executed
_after_ all modules have been loaded, right before handle_all_diagrams() is
called. (This allows using dia's python capabilities to modify diagrams
right before they are exported.)

Overall I like this feature and your patch is not far from inclusion ;-)

I'm having "dia_is_interactive = FALSE" if the -i option is provided,
however I already have half a mind to remove this limitation, but there are
implications to consider first.

Could elaborate a bit more about the implications? Or is it just that you don't have a use case yet?

[...]
To implement this feature, I ...

... split off the part where the python plug-in's dia_plugin_init() runs
'python-startup.py' into its own function run_script_oneshot().
ok.

... made the python plug-in's dia_plugin_init() use run_script_oneshot() to
avoid code redundancy.
ok.

... moved the definition of struct _PluginInfo from lib/plug-ins.c to
lib/plug-ins.h, because I need this struct in app/app_procs.c.
not ok. To avoid this please use dia_plugin_get_symbol().

... modified app/app_procs.c app_init() to include the -i option and stores
the provided filename in a local variable python_script.
ok, though I would prefer another short option, maybe -r and --run-script instead of --python?

... appended python_script to the list of variables that triffer
dia_is_interactive=FALSE
ok, but see above implications.

... added a block if(python_script) which checks if the python plug-in is
loaded, and does run_script_oneshot(python_script) when sensible.
ok.

I am not certain how to feel about moving a struct definition into a .h
file and I want to be able to pass the GList "files" to
run_script_oneshot() and the python interpreter before this is done. Then I
also consider creating patch sets to put as enhancement into the
bugtracker. For now, there is one big patch attached.

IMO the patch is not too big to be discussed (and finally be applied) in one piece.

What do you people think about this feature?

Haven't tried it yet. But with the above mentioned changes I'm fine with including it with standard Dia, if there are no unforeseen implications.

There are minor coding style glitches (tab size, placement of braces) but I can fix these before commiting.

Thanks,
        Hans

-------- Hans "at" Breuer "dot" Org -----------
Tell me what you need, and I'll tell you how to
get along without it.                -- Dilbert


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