Append extra KEY=val configs into the given config file.
(self, config_path, configs, config_fragments=None, mode='a')
| 270 | os.unlink(path) |
| 271 | |
| 272 | def write_configs(self, config_path, configs, config_fragments=None, mode='a'): |
| 273 | ''' |
| 274 | Append extra KEY=val configs into the given config file. |
| 275 | ''' |
| 276 | if config_fragments is None: |
| 277 | config_fragments = [] |
| 278 | for config_fragment in config_fragments: |
| 279 | self.print_cmd(['cat', config_fragment, '>>', config_path]) |
| 280 | if not self.dry_run: |
| 281 | with open(config_path, 'a') as config_file: |
| 282 | for config_fragment in config_fragments: |
| 283 | with open(config_fragment, 'r') as config_fragment_file: |
| 284 | for line in config_fragment_file: |
| 285 | config_file.write(line) |
| 286 | self.write_string_to_file(config_path, '\n'.join(configs), mode=mode) |
| 287 | |
| 288 | def write_string_to_file(self, path, string, mode='w'): |
| 289 | if mode == 'a': |
nothing calls this directly
no test coverage detected