def __really_delete_db(self): """ Delete the selected database. If the database is open, close it first. Then scan the database directory, deleting the files, and finally removing the directory. """ # close the database if the user has requested to delete the # active database if self.data_to_delete[PATH_COL] == self.active: self.dbstate.no_database() store, node = self.selection.get_selected() path = store.get_path(node) node = self.model.get_iter(path) filename = self.model.get_value(node, FILE_COL) try: with open(filename, "r") as name_file: file_name_to_delete = name_file.read() remove_filename(file_name_to_delete) directory = self.data_to_delete[1] for (top, dirs, files) in os.walk(directory): for filename in files: os.unlink(os.path.join(top, filename)) os.rmdir(directory) except (IOError, OSError) as msg: DbManager.ERROR(_("Could not delete Family Tree"), str(msg)) # rebuild the display self.__populate() self._select_default()
def __really_delete_db(self): """ Delete the selected database. If the database is open, close it first. Then scan the database directory, deleting the files, and finally removing the directory. """ # close the database if the user has requested to delete the # active database if self.data_to_delete[PATH_COL] == self.active: self.dbstate.no_database() store, node = self.selection.get_selected() path = store.get_path(node) node = self.model.get_iter(path) filename = conv_to_unicode(self.model.get_value(node, FILE_COL), 'utf8') try: name_file = open(filename, "r") file_name_to_delete = name_file.read() name_file.close() remove_filename(file_name_to_delete) directory = conv_to_unicode(self.data_to_delete[1], 'utf8') for (top, dirs, files) in os.walk(directory): for filename in files: os.unlink(os.path.join(top, filename)) os.rmdir(directory) except (IOError, OSError) as msg: DbManager.ERROR(_("Could not delete Family Tree"), str(msg)) # rebuild the display self.__populate()
def __really_delete_db(self): """ Delete the selected database. If the database is open, close it first. Then scan the database directory, deleting the files, and finally removing the directory. """ # close the database if the user has requested to delete the # active database if self.data_to_delete[PATH_COL] == self.active: self.dbstate.no_database() store, node = self.selection.get_selected() path = store.get_path(node) node = self.model.get_iter(path) filename = self.model.get_value(node, FILE_COL) try: with open(filename, "r") as name_file: file_name_to_delete = name_file.read() remove_filename(file_name_to_delete) directory = self.data_to_delete[1] for (top, dirs, files) in os.walk(directory): for filename in files: os.unlink(os.path.join(top, filename)) os.rmdir(directory) except (IOError, OSError) as msg: ErrorDialog( _("Could not delete Family Tree"), # parent-OK str(msg), parent=self.top) # rebuild the display self.__populate() self._select_default()