Apply PacmanConfiguration (Color, ParallelDownloads) to the target system's pacman.conf.
(self, pacman_config: PacmanConfiguration)
| 55 | PACMAN_CONF.copy(self._config_remote_path, preserve_metadata=True) |
| 56 | |
| 57 | def configure(self, pacman_config: PacmanConfiguration) -> None: |
| 58 | """Apply PacmanConfiguration (Color, ParallelDownloads) to the target system's pacman.conf.""" |
| 59 | if not self._config_remote_path or not self._config_remote_path.exists(): |
| 60 | return |
| 61 | |
| 62 | content = self._config_remote_path.read_text().splitlines() |
| 63 | result = [] |
| 64 | |
| 65 | for line in content: |
| 66 | if re.match(r'^#?\s*ParallelDownloads', line): |
| 67 | result.append(f'ParallelDownloads = {pacman_config.parallel_downloads}') |
| 68 | elif re.match(r'^#?\s*Color\s*$', line): |
| 69 | result.append('Color' if pacman_config.color else '#Color') |
| 70 | else: |
| 71 | result.append(line) |
| 72 | |
| 73 | self._config_remote_path.write_text('\n'.join(result) + '\n') |
no test coverage detected