Configuration file handling and setup — bornprofiler.config
¶
The user can set important paths in ~/.bornprofiler.cfg
. The file
is automatically created with default values if it does not exist.
Edit the file with a text editor.
In order to restore the default values, simply delete the config file.
Format¶
The configuration file is in “INI” format: Section titles and variable assignments:
[executables]
apbs = apbs
drawmembrane = /path/to/drawmembrane2a
[membrane]
Meaning of variables¶
- executables
- paths to binaries or just the name if they are found via
PATH
- membrane
- configuration variables for apbs-mem-setup and friends
Accessing the configuration¶
Important variables are stored in the dict configuration
. Any
variable can be accessed via the getter method of the
ConfigParser.SafeConfigParser
instance, cfg
:
from bornprofiler.config import cfg
varname = cfg.get(section, varname)
-
bornprofiler.config.
CONFIGNAME
= '/home/docs/.bornprofiler.cfg'¶ Default name for the configuration file.
-
bornprofiler.config.
cfg
= <bornprofiler.config.BPConfigParser instance>¶ cfg
is the instance ofBPConfigParser
that makes all global configuration data accessible
-
bornprofiler.config.
check_APBS
(name=None)[source]¶ Return ABPS version if apbs can be run and has the minimum required version.
Raises: error if it cannot be found (OSError ENOENT) or wrong version (EnvironmentError).
-
bornprofiler.config.
check_drawmembrane
(name=None)[source]¶ Return drawmembrane version or raise
EnvironmentError
if incompatible version of drawmembrane
-
bornprofiler.config.
check_setup
()[source]¶ Check if templates directories are setup and issue a warning and help.
-
bornprofiler.config.
configuration
= {'apbs': 'apbs', 'configfilename': '/home/docs/.bornprofiler.cfg', 'drawmembrane': 'draw_membrane2a'}¶ Dict containing important configuration variables, populated by
get_configuration()
(mainly a shortcut; usecfg
in most cases)
-
bornprofiler.config.
get_configuration
(filename='/home/docs/.bornprofiler.cfg')[source]¶ Reads and parses the configuration file.
Default values are loaded and then replaced with the values from
~/.bornprofiler.cfg
if that file exists. The global configuration instancebornprofiler.config.cfg
is updated.Normally, the configuration is only loaded when the
bornprofiler
package is imported but a re-reading of the configuration can be forced anytime by callingget_configuration()
.
-
bornprofiler.config.
get_template
(t)[source]¶ Find template file t and return its real path.
t can be a single string or a list of strings. A string should be one of
- a relative or absolute path,
- a file in one of the directories listed in
bornprofiler.config.path
, - a filename in the package template directory (defined in the template dictionary
bornprofiler.config.templates
) or - a key into
templates
.
The first match (in this order) is returned. If the argument is a single string then a single string is returned, otherwise a list of strings.
Arguments: t : template file or key (string or list of strings) Returns: os.path.realpath(t) (or a list thereof) Raises: ValueError
if no file can be located.
-
bornprofiler.config.
get_templates
(t)[source]¶ Find template file(s) t and return their real paths.
t can be a single string or a list of strings. A string should be one of
- a relative or absolute path,
- a file in one of the directories listed in
bornprofiler.config.path
, - a filename in the package template directory (defined in the template dictionary
bornprofiler.config.templates
) or - a key into
templates
.
The first match (in this order) is returned for each input argument.
Arguments: t : template file or key (string or list of strings) Returns: list of os.path.realpath(t) Raises: ValueError
if no file can be located.
-
bornprofiler.config.
path
= ['.', '/home/docs/.bornprofiler/qscripts', '/home/docs/.bornprofiler/templates']¶ Search path for user queuing scripts and templates. The internal package-supplied templates are always searched last via
bornprofiler.config.get_templates()
. Modifybornprofiler.config.path
directly in order to customize the template and qscript searching. By default it has the value['.', qscriptdir, templatesdir]
. (Note that it is not a good idea to have template files and qscripts with the same name as they are both searched on the same path.)
-
bornprofiler.config.
resource_basename
(resource)[source]¶ Last component of a resource (which always uses ‘/’ as sep).
-
bornprofiler.config.
setup
(filename='/home/docs/.bornprofiler.cfg')[source]¶ Prepare a default BornProfiler global environment.
- Create the global config file.
- Create the directories in which the user can store template and config files.
This function can be run repeatedly without harm.
-
bornprofiler.config.
templates
= {'array_ASU_workstations.ge': '/home/docs/checkouts/readthedocs.org/user_builds/bornprofiler/checkouts/latest/bornprofiler/templates/array_ASU_workstations.ge', 'array_SBCB_workstations.sge': '/home/docs/checkouts/readthedocs.org/user_builds/bornprofiler/checkouts/latest/bornprofiler/templates/array_SBCB_workstations.sge', 'bornions.dat': '/home/docs/checkouts/readthedocs.org/user_builds/bornprofiler/checkouts/latest/bornprofiler/templates/bornions.dat', 'drawmembrane2.bash': '/home/docs/checkouts/readthedocs.org/user_builds/bornprofiler/checkouts/latest/bornprofiler/templates/drawmembrane2.bash', 'dummy.in': '/home/docs/checkouts/readthedocs.org/user_builds/bornprofiler/checkouts/latest/bornprofiler/templates/dummy.in', 'mdummy.in': '/home/docs/checkouts/readthedocs.org/user_builds/bornprofiler/checkouts/latest/bornprofiler/templates/mdummy.in', 'mplaceion.in': '/home/docs/checkouts/readthedocs.org/user_builds/bornprofiler/checkouts/latest/bornprofiler/templates/mplaceion.in', 'mplaceion_memonly.in': '/home/docs/checkouts/readthedocs.org/user_builds/bornprofiler/checkouts/latest/bornprofiler/templates/mplaceion_memonly.in', 'placeion.in': '/home/docs/checkouts/readthedocs.org/user_builds/bornprofiler/checkouts/latest/bornprofiler/templates/placeion.in', 'q_ASU.sh': '/home/docs/checkouts/readthedocs.org/user_builds/bornprofiler/checkouts/latest/bornprofiler/templates/q_ASU.sh', 'q_SBCB.sh': '/home/docs/checkouts/readthedocs.org/user_builds/bornprofiler/checkouts/latest/bornprofiler/templates/q_SBCB.sh', 'q_array.sge': '/home/docs/checkouts/readthedocs.org/user_builds/bornprofiler/checkouts/latest/bornprofiler/templates/q_array.sge', 'q_local.sh': '/home/docs/checkouts/readthedocs.org/user_builds/bornprofiler/checkouts/latest/bornprofiler/templates/q_local.sh', 'solvation.in': '/home/docs/checkouts/readthedocs.org/user_builds/bornprofiler/checkouts/latest/bornprofiler/templates/solvation.in', 'solvation_no_membrane.in': '/home/docs/checkouts/readthedocs.org/user_builds/bornprofiler/checkouts/latest/bornprofiler/templates/solvation_no_membrane.in'}¶ Registry of all template files that come with the package.