load the ini-formatted config file from OUTPUT_DIR/Archivebox.conf
(out_dir: str=None)
| 645 | |
| 646 | |
| 647 | def load_config_file(out_dir: str=None) -> Optional[Dict[str, str]]: |
| 648 | """load the ini-formatted config file from OUTPUT_DIR/Archivebox.conf""" |
| 649 | |
| 650 | out_dir = out_dir or Path(os.getenv('OUTPUT_DIR', '.')).resolve() |
| 651 | config_path = Path(out_dir) / CONFIG_FILENAME |
| 652 | if config_path.exists(): |
| 653 | config_file = ConfigParser() |
| 654 | config_file.optionxform = str |
| 655 | config_file.read(config_path) |
| 656 | # flatten into one namespace |
| 657 | config_file_vars = { |
| 658 | key.upper(): val |
| 659 | for section, options in config_file.items() |
| 660 | for key, val in options.items() |
| 661 | } |
| 662 | # print('[i] Loaded config file', os.path.abspath(config_path)) |
| 663 | # print(config_file_vars) |
| 664 | return config_file_vars |
| 665 | return None |
| 666 | |
| 667 | |
| 668 | def write_config_file(config: Dict[str, str], out_dir: str=None) -> ConfigDict: |