[optionally] copy default config files into profile dir.
(self)
| 436 | self._in_init_profile_dir = False |
| 437 | |
| 438 | def init_config_files(self): |
| 439 | """[optionally] copy default config files into profile dir.""" |
| 440 | self.config_file_paths.extend(ENV_CONFIG_DIRS) |
| 441 | self.config_file_paths.extend(SYSTEM_CONFIG_DIRS) |
| 442 | # copy config files |
| 443 | path = Path(self.builtin_profile_dir) |
| 444 | if self.copy_config_files: |
| 445 | src = self.profile |
| 446 | |
| 447 | cfg = self.config_file_name |
| 448 | if path and (path / cfg).exists(): |
| 449 | self.log.warning( |
| 450 | "Staging %r from %s into %r [overwrite=%s]" |
| 451 | % (cfg, src, self.profile_dir.location, self.overwrite) |
| 452 | ) |
| 453 | self.profile_dir.copy_config_file(cfg, path=path, overwrite=self.overwrite) |
| 454 | else: |
| 455 | self.stage_default_config_file() |
| 456 | else: |
| 457 | # Still stage *bundled* config files, but not generated ones |
| 458 | # This is necessary for `ipython profile=sympy` to load the profile |
| 459 | # on the first go |
| 460 | files = path.glob("*.py") |
| 461 | for fullpath in files: |
| 462 | cfg = fullpath.name |
| 463 | if self.profile_dir.copy_config_file(cfg, path=path, overwrite=False): |
| 464 | # file was copied |
| 465 | self.log.warning("Staging bundled %s from %s into %r"%( |
| 466 | cfg, self.profile, self.profile_dir.location) |
| 467 | ) |
| 468 | |
| 469 | |
| 470 | def stage_default_config_file(self): |