Update our user-modifications config level with new data. :param tuple keypath: The key path identifying the sub-dict being updated. May be an empty tuple if the update is occurring at the topmost level. :param str key: The actual key re
(self, keypath: Tuple[str, ...], key: str, value: str)
| 1100 | ) |
| 1101 | |
| 1102 | def _modify(self, keypath: Tuple[str, ...], key: str, value: str) -> None: |
| 1103 | """ |
| 1104 | Update our user-modifications config level with new data. |
| 1105 | |
| 1106 | :param tuple keypath: |
| 1107 | The key path identifying the sub-dict being updated. May be an |
| 1108 | empty tuple if the update is occurring at the topmost level. |
| 1109 | |
| 1110 | :param str key: |
| 1111 | The actual key receiving an update. |
| 1112 | |
| 1113 | :param value: |
| 1114 | The value being written. |
| 1115 | """ |
| 1116 | # First, ensure we wipe the keypath from _deletions, in case it was |
| 1117 | # previously deleted. |
| 1118 | excise(self._deletions, keypath + (key,)) |
| 1119 | # Now we can add it to the modifications structure. |
| 1120 | data = self._modifications |
| 1121 | keypath_list = list(keypath) |
| 1122 | while keypath_list: |
| 1123 | subkey = keypath_list.pop(0) |
| 1124 | # TODO: could use defaultdict here, but...meh? |
| 1125 | if subkey not in data: |
| 1126 | # TODO: generify this and the subsequent 3 lines... |
| 1127 | data[subkey] = {} |
| 1128 | data = data[subkey] |
| 1129 | data[key] = value |
| 1130 | self.merge() |
| 1131 | |
| 1132 | def _remove(self, keypath: Tuple[str, ...], key: str) -> None: |
| 1133 | """ |
no test coverage detected