config
- Configuration¶
The config
module provides functions to interact with card10’s
configuration file (card10.cfg).
-
config.
set_string
(key, value)[source]¶ Write a string to the configuration file card10.cfg.
Both
key
andvalue
must be strings or must be convertible to a string using thestr()
function.key
must not contain spaces, control characters (including tabs), number signs ans equal signs.value
must not contain control characters (including tabs). Neither is allowed to contain the sub-string"execute_elf"
.The key/value pair is immediately written to the configuration file (card10.cfg). After the file is written, configuration is read again and the new value is available via
config.get_string()
.- Parameters
key (str) – Name of the configuration option.
value (str) – Value to write.
- Raises
OSError – If writing to the configuration file failed.
OSError – If key or value contain illegal characters.
ValueError – If key or value contain the sub-string
"execute_elf"
.
New in version 1.16.
-
config.
get_string
(key)[source]¶ Read a string from the configuration file card10.cfg.
key
must be a string or must be convertible to a string using thestr()
function.- Parameters
key (str) – Name of the configuration option.
- Return type
str
- Returns
Value of the configuration option.
- Raises
OSError – if the key is not present in the configuration.
New in version 1.16.