Get a variable from the configuration object. Note: Since we use the ConfigParser class, the section names are case-sensitive but the keys are not. Args: key: The key of the variable to be loaded. section: The section of the configuration object
(self, key: str, section: str | None = None)
| 76 | self.loaded_cfg.set(section, key, value) |
| 77 | |
| 78 | def get_variable(self, key: str, section: str | None = None) -> Any: |
| 79 | """Get a variable from the configuration object. |
| 80 | |
| 81 | Note: |
| 82 | Since we use the ConfigParser class, the section names are case-sensitive but the keys are not. |
| 83 | |
| 84 | Args: |
| 85 | key: The key of the variable to be loaded. |
| 86 | section: The section of the configuration object to read the variable from. |
| 87 | Defaults to None, in which case the default section is used. |
| 88 | |
| 89 | Returns: |
| 90 | The value of the variable. It is None if the key does not exist. |
| 91 | |
| 92 | Raises: |
| 93 | configparser.Error: If no section is specified and the default section is None. |
| 94 | """ |
| 95 | # resolve the section |
| 96 | if section is None: |
| 97 | if self.namespace is None: |
| 98 | raise configparser.Error("No section specified. Please specify a section or set StateFile.namespace.") |
| 99 | section = self.namespace |
| 100 | |
| 101 | return self.loaded_cfg.get(section, key, fallback=None) |
| 102 | |
| 103 | def delete_variable(self, key: str, section: str | None = None): |
| 104 | """Delete a variable from the configuration object. |
no outgoing calls
no test coverage detected