(self)
Delete the marked group
Delete the marked group
Delete the marked group
def delete_group(self):
        '''Delete the marked group'''

        if len(self.db.groups) > 1:
            title = self.groups[self.g_highlight].title
            self.control.draw_text(self.changed,
                                   (1, 0, 'Really delete group ' + title + '? '
                                    '[y/(n)]'))
        else:
            self.control.draw_text(self.changed,
                                   (1, 0, 'At least one group is needed!'),
                                   (3, 0, 'Press any key'))
            if self.control.any_key() == -1:
                self.close()
        while True:
            try:
                e = self.control.stdscr.getch()
            except KeyboardInterrupt:
                e = 4
            if e == ord('y'):
                if self.remote is True:
                    root = self.groups[self.g_highlight].id_
                    last_mod = (self.groups[self.g_highlight]
                                    .last_mod.timetuple())
                    db_buf = self.client().delete_group(str(root).encode(),
                                                        last_mod)
                    if self.check_answer(db_buf) is not False:
                        self.reload_remote_db(db_buf)
                else:
                    try:
                        self.groups[self.g_highlight].remove_group()
                    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 (not self.cur_root.children and
                                self.cur_root is not self.db.root_group):
                            self.cur_root = self.cur_root.parent
                        self.changed = True

                        if (self.g_highlight >= len(self.groups) - 1 and
                                self.g_highlight != 0):
                            self.g_highlight -= 1
                        self.e_highlight = 0
                        self.sort_tables(True, True)
                break
            elif e == 4:
                self.close()
            elif e == cur.KEY_RESIZE:
                self.control.resize_all()
            else:
                break
def delete_group ( self ) : if len ( self . db . groups ) > 1 : title = self . groups [ self . g_highlight ] . title self . control . draw_text ( self . changed , ( 1 , 0 , 'Really delete group ' + title + '? ' '[y/(n)]' ) ) else : self . control . draw_text ( self . changed , ( 1 , 0 , 'At least one group is needed!' ) , ( 3 , 0 , 'Press any key' ) ) if self . control . any_key ( ) == - 1 : self . close ( ) while True : try : e = self . control . stdscr . getch ( ) except KeyboardInterrupt : e = 4 if e == ord ( 'y' ) : if self . remote is True : root = self . groups [ self . g_highlight ] . id_ last_mod = ( self . groups [ self . g_highlight ] . last_mod . timetuple ( ) ) db_buf = self . client ( ) . delete_group ( str ( root ) . encode ( ) , last_mod ) if self . check_answer ( db_buf ) is not False : self . reload_remote_db ( db_buf ) else : try : self . groups [ self . g_highlight ] . remove_group ( ) 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 ( not self . cur_root . children and self . cur_root is not self . db . root_group ) : self . cur_root = self . cur_root . parent self . changed = True if ( self . g_highlight >= len ( self . groups ) - 1 and self . g_highlight != 0 ) : self . g_highlight -= 1 self . e_highlight = 0 self . sort_tables ( True , True ) break elif e == 4 : self . close ( ) elif e == cur . KEY_RESIZE : self . control . resize_all ( ) else : break