def shred_paths(self, paths, shred_settings=False, quit_when_done=False): """Shred file or folders When shredding_settings=True: If user confirms to delete, then returns True. If user aborts, returns False. When quit_when_done=True: Always returns False to remove function from the idle queue. """ # create a temporary cleaner object backends['_gui'] = Cleaner.create_simple_cleaner(paths) # preview and confirm operations = {'_gui': ['files']} self.preview_or_run_operations(False, operations) if GuiBasic.delete_confirmation_dialog(self, mention_preview=False, shred_settings=shred_settings): # delete self.preview_or_run_operations(True, operations) if shred_settings: return True if quit_when_done: GLib.idle_add(self.close, priority=GObject.PRIORITY_LOW) # user aborted return False
def shred_paths(self, paths, shred_settings=False): """Shred file or folders When shredding_settings=True: If user confirms to delete, then returns True. If user aborts, returns False. """ # create a temporary cleaner object backends['_gui'] = Cleaner.create_simple_cleaner(paths) # preview and confirm operations = {'_gui': ['files']} self.preview_or_run_operations(False, operations) if self._confirm_delete(False, shred_settings): # delete self.preview_or_run_operations(True, operations) if shred_settings: return True if self._auto_exit: GLib.idle_add(self.close, priority=GObject.PRIORITY_LOW) # user aborted return False
def __init__(self, pathname, xlate_cb=None): """Create cleaner from XML in pathname. If xlate_cb is set, use it as a callback for each translate-able string. """ self.action = None self.cleaner = Cleaner.Cleaner() self.option_id = None self.option_name = None self.option_description = None self.option_warning = None self.vars = {} self.xlate_cb = xlate_cb # action,cleaner,option_id,option_name,option_description,option_warning,vars,xlate_cb 메서드 값 초기화 if self.xlate_cb is None: self.xlate_mode = False self.xlate_cb = lambda x, y=None: None # do nothing #만약 xlate_cb 메서드 값이 None이면 xlate_mode는 false가 되고, xlate_cb는 x,y값이 None이면 None값을 돌려주는 함수가 된다. else: self.xlate_mode = True #xlate_cb가 None이 아니면 xlate_mode는 True가 된다. dom = xml.dom.minidom.parse(pathname) #xml형식으로된 pathname을 xml파싱이 가능한 형식으로 변형해서 dom에 저장 self.handle_cleaner(dom.getElementsByTagName('cleaner')[0])
def add_section(self, cleaner_id, name): """Add a section (cleaners)""" self.cleaner_ids.append(cleaner_id) self.cleaners[cleaner_id] = Cleaner.Cleaner() self.cleaners[cleaner_id].id = cleaner_id self.cleaners[cleaner_id].name = name self.cleaners[cleaner_id].description = _('Imported from winapp2.ini')
def actions_to_cleaner(action_strs): """Given multiple action XML fragments, return one cleaner""" cleaner = Cleaner() count = 1 for action_str in action_strs: dom = parseString(action_str) action_node = dom.childNodes[0] command = action_node.getAttribute('command') provider = None for actionplugin in ActionProvider.plugins: if actionplugin.action_key == command: provider = actionplugin(action_node) cleaner.add_action('option%d' % count, provider) cleaner.add_option('option%d' % count, 'name%d' % count, 'description%d' % count) count = count + 1 return cleaner
def add_section(self, cleaner_id, name): """Add a section (cleaners)""" self.cleaner_ids.append(cleaner_id) self.cleaners[cleaner_id] = Cleaner.Cleaner() self.cleaners[cleaner_id].id = cleaner_id self.cleaners[cleaner_id].name = name self.cleaners[cleaner_id].description = _('Imported from winapp2.ini') # The detect() function in this module effectively does what # auto_hide() does, so this avoids redundant, slow processing. self.cleaners[cleaner_id].auto_hide = lambda: False
def cb_wipe_free_space(self, action, param): """callback to wipe free space in arbitrary folder""" path = GuiBasic.browse_folder(self._window, _("Choose a folder"), multiple=False, stock_button=_('_OK')) if not path: # user cancelled return backends['_gui'] = Cleaner.create_wipe_cleaner(path) # execute operations = {'_gui': ['free_disk_space']} self._window.preview_or_run_operations(True, operations)
def cb_wipe_free_space(self, action): """callback to wipe free space in arbitrary folder""" path = GuiBasic.browse_folder(self.window, _("Choose a folder"), multiple=False, stock_button=gtk.STOCK_OK) if not path: # user cancelled return backends['_gui'] = Cleaner.create_wipe_cleaner(path) # execute operations = {'_gui': ['free_disk_space']} self.preview_or_run_operations(True, operations)
def shred_paths(self, paths): """Shred file or folders If user confirms and files are deleted, returns True. If user aborts, returns False. """ # create a temporary cleaner object backends['_gui'] = Cleaner.create_simple_cleaner(paths) # preview and confirm operations = {'_gui': ['files']} self.preview_or_run_operations(False, operations) if GuiBasic.delete_confirmation_dialog(self.window, mention_preview=False): # delete self.preview_or_run_operations(True, operations) return True # user aborted return False
def shred_paths(self, paths): """Shred file or folders If user confirms and files are deleted, returns True. If user aborts, returns False. """ # create a temporary cleaner object backends['_gui'] = Cleaner.create_simple_cleaner(paths) # preview and confirm operations = {'_gui': ['files']} self.preview_or_run_operations(False, operations) if GuiBasic.delete_confirmation_dialog(self, mention_preview=False): # delete self.preview_or_run_operations(True, operations) return True # user aborted return False
def actions_to_cleaner(action_strs): """Given multiple action XML fragments, return one cleaner""" cleaner = Cleaner() for count, action_str in enumerate(action_strs, start=1): dom = parseString(action_str) action_node = dom.childNodes[0] command = action_node.getAttribute('command') provider = None for actionplugin in ActionProvider.plugins: if actionplugin.action_key == command: provider = actionplugin(action_node) cleaner.add_action('option%d' % count, provider) cleaner.add_option('option%d' % count, 'name%d' % count, 'description%d' % count) return cleaner
def __init__(self, pathname, xlate_cb=None): """Create cleaner from XML in pathname. If xlate_cb is set, use it as a callback for each translate-able string. """ self.action = None self.cleaner = Cleaner.Cleaner() self.option_id = None self.option_name = None self.option_description = None self.option_warning = None self.xlate_cb = xlate_cb if self.xlate_cb is None: self.xlate_mode = False self.xlate_cb = lambda x, y=None: None # do nothing else: self.xlate_mode = True dom = xml.dom.minidom.parse(pathname) self.handle_cleaner(dom.getElementsByTagName('cleaner')[0])
def shred_paths(self, paths, shred_settings=False): """Shred file or folders When shredding_settings=True: If user confirms to delete, then returns True. If user aborts, returns False. When quit_when_done=True: Always returns False to remove function from the idle queue. """ # create a temporary cleaner object backends['_gui'] = Cleaner.create_simple_cleaner(paths) # preview and confirm operations = {'_gui': ['files']} self.preview_or_run_operations(False, operations) if self._confirm_delete(False, shred_settings): # delete self.preview_or_run_operations(True, operations) return True # user aborted return False