30. main
— pyFormex main module¶
This module contains the main function of pyFormex, which is run by the startup script.
30.1. Functions defined in module main¶
- main.run_docmodule(module)[source]¶
Print autogenerated documentation for the module.
module is a pyFormex module dotted path. The leading pyformex. may be omitted.
- main.loadUserConfig()[source]¶
Load the pyFormex configuration
Notes
This function should be called to create a proper configuration when pyFormex is imported in Python and not started from the pyformex command.
- main.savePreferences()[source]¶
Save the preferences.
The name of the preferences file is determined at startup from the configuration files, and saved in
pyformex.preffile
. If a local preferences file was read, it will be saved there. Otherwise, it will be saved as the user preferences, possibly creating that file. Ifpyformex.preffile
is None, preferences are not saved.
- main.activateWarningFilters()[source]¶
Activate the warning filters
First time activation of the warning filters and customized warning formatting.
- main.override_config(option, setting, delete=True)[source]¶
Override a config setting with a command line option
- Parameters:
Notes
If the option was given, its value is written into the corresponding setting and the option is deleted.
- main.run(args=[])[source]¶
The pyFormex main function.
After pyFormex launcher script has correctly set up the Python import paths, this function is executed. It is responsible for reading the configuration file(s), processing the command line options and starting the application.
The basic configuration file is ‘pyformexrc’ located in the pyFormex main directory. It should always be present and be left unchanged. If you want to make changes, copy (parts of) this file to another location where you can change them. Then make sure pyFormex reads you modifications file. By default, pyFormex will try to read the following configuration files if they are present (and in this order):
default settings: <pyformexdir>/pyformexrc (always loaded) system-wide settings: /etc/pyformex.conf user settings: <configdir>/pyformex/pyformex.conf local settings $PWD/.pyformexrc
Also, an extra config file can be specified in the command line, using the –config option. The system-wide and user settings can be skipped by using the –nodefaultconfig option.
Config files are loaded in the above order. Settings always override those loaded from a previous file.
When pyFormex exits, the preferences that were changed are written to the last read config file. Changed settings are those that differ from the settings obtained after loading all but the last config file. If none of the optional config files exists, a new user settings file will be created, and an error will occur if the <configdir> path is not writable.