1199 def configoverride(self, overrides, source=""): |
1199 def configoverride(self, overrides, source=""): |
1200 """Context manager for temporary config overrides |
1200 """Context manager for temporary config overrides |
1201 `overrides` must be a dict of the following structure: |
1201 `overrides` must be a dict of the following structure: |
1202 {(section, name) : value}""" |
1202 {(section, name) : value}""" |
1203 backups = {} |
1203 backups = {} |
1204 for (section, name), value in overrides.items(): |
1204 try: |
1205 backups[(section, name)] = self.backupconfig(section, name) |
1205 for (section, name), value in overrides.items(): |
1206 self.setconfig(section, name, value, source) |
1206 backups[(section, name)] = self.backupconfig(section, name) |
1207 yield |
1207 self.setconfig(section, name, value, source) |
1208 for __, backup in backups.items(): |
1208 yield |
1209 self.restoreconfig(backup) |
1209 finally: |
1210 # just restoring ui.quiet config to the previous value is not enough |
1210 for __, backup in backups.items(): |
1211 # as it does not update ui.quiet class member |
1211 self.restoreconfig(backup) |
1212 if ('ui', 'quiet') in overrides: |
1212 # just restoring ui.quiet config to the previous value is not enough |
1213 self.fixconfig(section='ui') |
1213 # as it does not update ui.quiet class member |
|
1214 if ('ui', 'quiet') in overrides: |
|
1215 self.fixconfig(section='ui') |
1214 |
1216 |
1215 class paths(dict): |
1217 class paths(dict): |
1216 """Represents a collection of paths and their configs. |
1218 """Represents a collection of paths and their configs. |
1217 |
1219 |
1218 Data is initially derived from ui instances and the config files they have |
1220 Data is initially derived from ui instances and the config files they have |