Initialize an empty configuration, if necessary
(*, log=True)
| 110 | |
| 111 | |
| 112 | def init_configuration(*, log=True): |
| 113 | """Initialize an empty configuration, if necessary""" |
| 114 | if not os.path.exists(bleachbit.options_dir): |
| 115 | General.makedirs(bleachbit.options_dir) |
| 116 | if os.path.lexists(bleachbit.options_file): |
| 117 | if log: |
| 118 | logger.debug('Deleting configuration: %s', bleachbit.options_file) |
| 119 | os.remove(bleachbit.options_file) |
| 120 | with open(bleachbit.options_file, 'w', encoding='utf-8-sig') as f_ini: |
| 121 | f_ini.write('[bleachbit]\n') |
| 122 | if os.name == 'nt' and bleachbit.portable_mode: |
| 123 | f_ini.write('[Portable]\n') |
| 124 | for section in options.config.sections(): |
| 125 | options.config.remove_section(section) |
| 126 | options.restore() |
| 127 | |
| 128 | |
| 129 | class Options: |