def delete_marked(self): if not confirm( '<p>' + _('The marked files and folders will be ' '<b>permanently deleted</b>. Are you sure?') + '</p>', 'check_library_editor_delete', self): return # Sort the paths in reverse length order so that we can be sure that # if an item is in another item, the sub-item will be deleted first. items = sorted(self.all_items, key=lambda x: len(x.text(1)), reverse=True) for it in items: if it.checkState(1): try: p = os.path.join(self.db.library_path, unicode(it.text(1))) if os.path.isdir(p): delete_tree(p) else: delete_file(p) except: prints( 'failed to delete', os.path.join(self.db.library_path, unicode(it.text(1)))) self.run_the_check()
def remove_format(self, book_id, fmt, fname, path): path = self.format_abspath(book_id, fmt, fname, path) if path is not None: try: delete_file(path) except: import traceback traceback.print_exc()
def do_delete(self, x): if os.path.isdir(x): delete_tree(x) else: delete_file(x) try: os.rmdir(os.path.dirname(x)) except OSError as e: if e.errno != errno.ENOTEMPTY: raise
def do_delete(self, tdir): if os.path.exists(tdir): try: for x in os.listdir(tdir): x = os.path.join(tdir, x) if os.path.isdir(x): delete_tree(x) else: delete_file(x) finally: shutil.rmtree(tdir)
def remove_custom_recipe(id_): from calibre.web.feeds.recipes import custom_recipes id_ = str(int(id_)) existing = custom_recipes.get(id_, None) if existing is not None: bdir = os.path.dirname(custom_recipes.file_path) fname = existing[1] del custom_recipes[id_] try: delete_file(os.path.join(bdir, fname)) except: pass
def delete_marked(self): if not confirm('<p>'+_('The marked files and folders will be ' '<b>permanently deleted</b>. Are you sure?') + '</p>', 'check_library_editor_delete', self): return # Sort the paths in reverse length order so that we can be sure that # if an item is in another item, the sub-item will be deleted first. items = sorted(self.all_items, key=lambda x: len(x.text(1)), reverse=True) for it in items: if it.checkState(1): try: p = os.path.join(self.db.library_path ,unicode(it.text(1))) if os.path.isdir(p): delete_tree(p) else: delete_file(p) except: prints('failed to delete', os.path.join(self.db.library_path, unicode(it.text(1)))) self.run_the_check()