(self)
Delete marked entry
Delete marked entry
Delete marked entry
def delete_entry(self):
        '''Delete marked entry'''

        title = self.entries[self.e_highlight].title
        self.control.draw_text(self.changed,
                               (1, 0,
                                'Really delete entry ' + title + '? [y/(n)]'))
        while True:
            try:
                e = self.control.stdscr.getch()
            except KeyboardInterrupt:
                e = 4
            if e == ord('y'):
                if self.remote is True:
                    entry_uuid = self.entries[self.e_highlight].uuid
                    last_mod = (self.entries[self.e_highlight]
                                    .last_mod.timetuple())

                    db_buf = self.client().delete_entry(entry_uuid, last_mod)
                    if self.check_answer(db_buf) is not False:
                        self.reload_remote_db(db_buf)

                        if not self.entries:
                            self.cur_win = 0
                        if (self.e_highlight >= len(self.entries) and
                                self.e_highlight != 0):
                            self.e_highlight -= 1
                else:
                    try:
                        self.entries[self.e_highlight].remove_entry()
                    except KPError as err:
                        self.control.draw_text(self.changed,
                                               (1, 0, err.__str__()),
                                               (4, 0, 'Press any key.'))
                        if self.control.any_key() == -1:
                            self.close()
                    else:
                        if self.groups[self.g_highlight].id_ == 0:
                            del (self.groups[self.g_highlight]
                                     .entries[self.e_highlight]) 
                        self.sort_tables(True, True)
                        self.changed = True
                        if not self.entries:
                            self.cur_win = 0
                        if (self.e_highlight >= len(self.entries) and
                                self.e_highlight != 0):
                            self.e_highlight -= 1
                break
            elif e == 4:
                self.close()
            elif e == cur.KEY_RESIZE:
                self.control.resize_all()
            else:
                break
def delete_entry ( self ) : title = self . entries [ self . e_highlight ] . title self . control . draw_text ( self . changed , ( 1 , 0 , 'Really delete entry ' + title + '? [y/(n)]' ) ) while True : try : e = self . control . stdscr . getch ( ) except KeyboardInterrupt : e = 4 if e == ord ( 'y' ) : if self . remote is True : entry_uuid = self . entries [ self . e_highlight ] . uuid last_mod = ( self . entries [ self . e_highlight ] . last_mod . timetuple ( ) ) db_buf = self . client ( ) . delete_entry ( entry_uuid , last_mod ) if self . check_answer ( db_buf ) is not False : self . reload_remote_db ( db_buf ) if not self . entries : self . cur_win = 0 if ( self . e_highlight >= len ( self . entries ) and self . e_highlight != 0 ) : self . e_highlight -= 1 else : try : self . entries [ self . e_highlight ] . remove_entry ( ) except KPError as err : self . control . draw_text ( self . changed , ( 1 , 0 , err . __str__ ( ) ) , ( 4 , 0 , 'Press any key.' ) ) if self . control . any_key ( ) == - 1 : self . close ( ) else : if self . groups [ self . g_highlight ] . id_ == 0 : del ( self . groups [ self . g_highlight ] . entries [ self . e_highlight ] ) self . sort_tables ( True , True ) self . changed = True if not self . entries : self . cur_win = 0 if ( self . e_highlight >= len ( self . entries ) and self . e_highlight != 0 ) : self . e_highlight -= 1 break elif e == 4 : self . close ( ) elif e == cur . KEY_RESIZE : self . control . resize_all ( ) else : break