esm_rcfile package¶
Top-level package for ESM RCFile.
Submodules¶
esm_rcfile.esm_rcfile module¶
Usage¶
This package contains functions to set, get, and use entries stored in the esmtoolsrc file.
To use ESM RCFile in a project:
import esm_rcfile
You can set specific values in the ~/.esmtoolsrc
with:
set_rc_entry(key, value)
For example:
>>> set_rc_entry("SCOPE_CONFIG", "/pf/a/a270077/Code/scope/configs/")
Retriving an entry:
>>> fpath = get_rc_entry("FUNCTION_PATH")
>>> print(fpath)
/pf/a/a270077/Code/esm_tools/esm_tools/configs
With a default value for a non-existing key:
>>> scope_config = get_rc_entry("SCOPE_CONFIG", "/dev/null")
>>> print(scope_config)
/dev/null
Without a default value, you get EsmRcfileError
:
>>> echam_namelist = get_rc_entry("ECHAM_NMLDIR")
EsmRcFileError: No value for ECHAM_NMLDIR found in esmtoolsrc file!!
This error is also raised if there is no ~/.esmtoolsrc
file, and no default
is provided.
You can also get the entire rcfile as a dict:
>>> rcdict = import_rc_file()
API Documentation¶
-
esm_rcfile.esm_rcfile.
get_rc_entry
(key, default=None)[source]¶ Gets a specific entry
Parameters: - key (str) –
- default (str) –
Returns: Value for key, or default if provided
Return type: str
Raises: - Raised if key cannot be found in the rcfile and no default is provided * Raised if the esmtoolsrc file cannot be found and no default is provided.