MCPcopy Create free account
hub / github.com/bleachbit/bleachbit / restore

Method restore

bleachbit/Options.py:415–450  ·  view source on GitHub ↗

Restore saved options from disk Abandons any changes not written to disk.

(self)

Source from the content-addressed store, hash-verified

413 self.overrides.clear()
414
415 def restore(self):
416 """Restore saved options from disk
417
418 Abandons any changes not written to disk.
419 """
420 with self._flush_lock:
421 self.__cancel_flush_timer()
422 self._dirty = False
423 # Reading configuration merges with existing data,
424 # so clear it first.
425 for section in self.config.sections():
426 self.config.remove_section(section)
427 try:
428 self.config.read(bleachbit.options_file, encoding='utf-8-sig')
429 except:
430 logger.exception("Error reading application's configuration")
431 if not self.config.has_section("bleachbit"):
432 self.config.add_section("bleachbit")
433 if not self.config.has_section("hashpath"):
434 self.config.add_section("hashpath")
435 if not self.config.has_section("list/shred_drives"):
436 from bleachbit.FileUtilities import guess_overwrite_paths
437 try:
438 self.set_list('shred_drives', guess_overwrite_paths())
439 except:
440 logger.exception(
441 _("Error when setting the default drives to shred."))
442 # BleachBit upgrade or first start ever
443 if not self.config.has_option('bleachbit', 'version') or \
444 self.get('version') != bleachbit.APP_VERSION:
445 if self.config.has_option('bleachbit', 'version'):
446 self.old_version = self.get('version')
447 self.set('first_start', True)
448
449 # set version
450 self.set("version", bleachbit.APP_VERSION)
451
452 def set(self, key, value, section='bleachbit'):
453 """Set a general option"""

Callers 4

__init__Method · 0.95
test_OptionsMethod · 0.80
_patch_options_pathsMethod · 0.80
init_configurationFunction · 0.80

Calls 8

__cancel_flush_timerMethod · 0.95
set_listMethod · 0.95
getMethod · 0.95
setMethod · 0.95
guess_overwrite_pathsFunction · 0.90
readMethod · 0.80
add_sectionMethod · 0.80
has_optionMethod · 0.45

Tested by 1

test_OptionsMethod · 0.64