Retrieve the config data for the specified section. Returns the data as a dictionary, or an empty dictionary if the file doesn't exist.
(self, section_name: str)
| 53 | return os.path.join(self.config_dir, section_name + ".json") |
| 54 | |
| 55 | def get(self, section_name: str) -> Any: |
| 56 | """Retrieve the config data for the specified section. |
| 57 | |
| 58 | Returns the data as a dictionary, or an empty dictionary if the file |
| 59 | doesn't exist. |
| 60 | """ |
| 61 | filename = self.file_name(section_name) |
| 62 | if os.path.isfile(filename): |
| 63 | with open(filename, encoding="utf-8") as f: |
| 64 | return json.load(f) |
| 65 | else: |
| 66 | return {} |
| 67 | |
| 68 | def set(self, section_name: str, data: Any) -> None: |
| 69 | """Store the given config data.""" |