Re: gypsthon patch (fwd)

From: Martin Sevior (msevior@physics.unimelb.edu.au)
Date: Fri Dec 06 2002 - 05:27:34 EST

  • Next message: Martin Sevior: "Re: gypsthon patch"

    ---------- Forwarded message ----------
    Date: Fri, 06 Dec 2002 09:30:36 +0100
    From: Mauro Colorio <linuxbox@interfree.it>
    To: msevior@physics.unimelb.edu.au
    Subject: Re: gypsthon patch

    > HI Maurio,

    Mauro, I'm MAURO!!:)

    > I haven't tried your code yet but I see no reason it won't work. This
    > is great! I've always wanted to script abiword with python.
    >
    > But I have a question:
    >
    > How does one run python scripts now? What is the procedure for running
    > python scripts.
    >

    in the code or in abiword?
    well in abiword you just install the plugin this add a menu into Tools
    menu, and selecting that menu item it will prompt you a file select dialog,
    when you select the script abiword runs it in an embedded python
    interpreter.

    for the code exentially is describen in the Gypsython.cpp code

      Py_Initialize(); //initialize the python interpreter

      initgypsython(); // initialized the faked abiword module for python

       // Well this can prevent to do a import gypsython in the script...but
    it's so ugly!!
       sprintf(loadmodulestring,
              "import sys\n"
              "import os\n"
              "import string\n"
              "import gypsython\n" // I need my own namespace:)
              "(filepath, filename) = os.path.split('%s')\n" // if someone knows a
    better way to do this..
       "sys.path.append(filepath)\n__import__(filename)",m_sModulePath);
       PyRun_SimpleString(loadmodulestring);

    loads and runs the script selected

       Py_Finalize();

    finalize the python interpreter

    that's all:)

    ciao
    Mauro



    This archive was generated by hypermail 2.1.4 : Fri Dec 06 2002 - 05:29:10 EST