OOF2: The Manual
It is first necessary to tell Python how to find the extension, and then to tell OOF2 to load it.
For an extension to be used by OOF2 it must be located in a directory that is in Python's path — the list of directories that Python searches when it imports a module. You can check the path by running
python -c "import sys; print(sys.path)" in a terminal window.
If the directory containing the extension is not listed, there are a number of ways to add it. In all of these examples, replace the word “directory” with the file system path to the directory containing the extension module.
-
Set the
PYTHONPATHenvironment variable. The way that is done depends on which version of the Unix shell you're using. In bash, for example, you would typeexport PYTHONPATH=$PYTHONPATH:directoryto append the directory to an existing path. This will apply to all future OOF2 sessions and any other Python programs started in the current terminal window. To make this change apply to all future terminal windows, put the export line in your shell's start-up file (
~/.profilein bash). -
Start OOF2 with the
--pathdir=directoryoption, which will add "directory" to the path just for that session of OOF2 and won't affect any other Python programs. Equivalently, in bash and maybe other shells, you can start OOF2 like this:PYTHONPATH=directory oof2 -
To make the change for all future OOF2 sessions, but not affect any other Python programs, insert the line
sys.path.append("directory")in the
.oof2rcfile in your home directory.
There are a few different ways of loading external extension modules. They all rely on having the extension's installation directory in the Python path, as explained in Section 7.4.1. The main differences between the methods are
-
Whether they load the module when OOF2 starts or later on in the session.
-
Whether the loading is done by an OOF2 menu command or directly by Python. If it's loaded by a command, the command will be saved in the session log, and the module will be reloaded if the log is reloaded.
-
Whether they apply to all future OOF2 sessions or just the current one.
The list below contains all the options. In each example, replace “oofextension” with the name of your extension:
-
Run the command OOF.File.Load.Module from the File menu in the main OOF2 window, and type the module name in the dialog box. This will load the module using a scriptable command in the current OOF2 session.
-
Put the line
OOF.File.Load.Module(module="oofextension")in the
.oof2rcin your home directory. This will load the module using a scriptable menu command in all future OOF2 sessions. -
Start OOF2 with the
--importoption, like this:oof2 --import=oofextensionThis loads the module at start-up time without using a menu command, and works only on the current session. Modules loaded with
--importare loaded before the.oof2rcfile is read, so this method won't work if the path to the module is set in.oof2rc. If you need to adjust the path at run time, you can use--pathdirin conjunction with--import:oof2 --pathdir=directory --import=oofextension -
Type the line
import oofextensionin the Console Window during an OOF2 session. This loads the module for the current session without using a menu command.
-
Put the line
import oofextensionin the
.oof2rcin your home directory. This will load the module without using a menu command in all future OOF2 sessions.
It is permissable to import a module more than once and by more than one method. Only the first import will have an effect, though.



