(self)
The database browser.
The database browser.
The database browser .
def db_browser(self):
        '''The database browser.'''

        unlocked_state = {
            cur.KEY_F1: self.control.dbbrowser_help,
            ord('e'): self.exit2main,
            ord('q'): self.quit_kpc,
            4: self.quit_kpc,
            ord('c'): self.copy_password,
            ord('b'): self.copy_username,
            ord('o'): self.open_url,
            ord('s'): self.pre_save,
            ord('S'): self.pre_save_as,
            ord('x'): self.save_n_quit,
            ord('L'): self.pre_lock,
            ord('P'): self.change_db_password,
            ord('g'): self.create_group,
            ord('G'): self.create_sub_group,
            ord('y'): self.create_entry,
            ord('d'): self.pre_delete,
            ord('f'): self.find_entries,
            ord('/'): self.find_entries,
            ord('t'): self.edit_title,
            ord('u'): self.edit_username,
            ord('U'): self.edit_url,
            ord('C'): self.edit_comment,
            ord('p'): self.edit_password,
            ord('E'): self.edit_date,
            ord('H'): self.show_password,
            ord('m'): self.move,
            cur.KEY_RESIZE: self.control.resize_all,
            NL: self.go2sub,
            cur.KEY_BACKSPACE: self.go2parent,
            DEL: self.go2parent,
            cur.KEY_DOWN: self.nav_down,
            ord('j'): self.nav_down,
            cur.KEY_UP: self.nav_up,
            ord('k'): self.nav_up,
            cur.KEY_LEFT: self.nav_left,
            ord('h'): self.nav_left,
            cur.KEY_RIGHT: self.nav_right,
            ord('l'): self.nav_right,
            ord('r'): self.reload_remote_db}

        locked_state = {
            ord('q'): self.quit_kpc,
            4: self.quit_kpc,
            cur.KEY_DOWN: self.nav_down_lock,
            ord('j'): self.nav_down_lock,
            cur.KEY_UP: self.nav_up_lock,
            ord('k'): self.nav_up_lock,
            NL: self.unlock_db,
            ord('1'): self.unlock_with_password,
            ord('2'): self.unlock_with_keyfile,
            ord('3'): self.unlock_with_both}

        move_states = {
            ord('e'): self.exit2main,
            ord('q'): self.quit_kpc,
            4: self.quit_kpc,
            cur.KEY_DOWN: self.nav_down,
            ord('j'): self.nav_down,
            cur.KEY_UP: self.nav_up,
            ord('k'): self.nav_up,
            cur.KEY_LEFT: self.go2parent,
            ord('h'): self.go2parent,
            cur.KEY_RIGHT: self.go2sub,
            ord('l'): self.go2sub,
            NL: self.move_group_or_entry,
            cur.KEY_BACKSPACE: self.move2root,
            DEL: self.move2root,
            ESC: self.move_abort,
            cur.KEY_F1: self.control.move_help}

        exceptions = (ord('s'), ord('S'), ord('P'), ord('t'), ord('p'), 
                      ord('u'), ord('U'), ord('C'), ord('E'), ord('H'), 
                      ord('g'), ord('d'), ord('y'), ord('f'), ord('/'),
                      cur.KEY_F1, cur.KEY_RESIZE)

        while True:
            old_g_highlight = self.g_highlight
            old_e_highlight = self.e_highlight
            old_window = self.cur_win
            old_root = self.cur_root
    
            if (self.control.config['lock_db'] and self.state == 0 and
                    self.db.filepath is not None):
                self.lock_timer = threading.Timer(
                    self.control.config['lock_delay'],
                    self.pre_lock)
                self.lock_timer.start()
            try:
                c = self.control.stdscr.getch()
            except KeyboardInterrupt:
                c = 4
            if type(self.lock_timer) is threading.Timer:
                self.lock_timer.cancel()
            if self.state == 0:
                if c == ord('\t'):  # Switch group/entry view with tab.
                    if self.cur_win == 0:
                        c = cur.KEY_RIGHT
                    else:
                        c = cur.KEY_LEFT
                if c in unlocked_state:
                    unlocked_state[c]()
                if c == ord('e'):
                    return False
                # 'cause 'L' changes state
                if self.state == 0 or self.state == 4:  
                    if ((self.cur_win == 0 and
                         old_g_highlight != self.g_highlight) or
                        c in exceptions or
                        old_window != self.cur_win or
                        old_root is not self.cur_root):
                        self.control.show_groups(self.g_highlight, self.groups,
                                                 self.cur_win, self.g_offset,
                                                 self.changed, self.cur_root)
                    if ((self.cur_win == 1 and
                         old_e_highlight != self.e_highlight) or
                        c in exceptions or
                        old_window != self.cur_win or
                        old_g_highlight != self.g_highlight or
                        old_root is not self.cur_root):
                        self.control.show_entries(self.e_highlight, 
                                                  self.entries,
                                                  self.cur_win, self.e_offset)
            elif self.state == 1 and c in locked_state:
                locked_state[c]()
                if self.state == 1:  # 'cause 'L' changes state
                    self.control.draw_lock_menu(self.changed,
                                                self.lock_highlight,
                                                (1, 0, 'Use a password (1)'),
                                                (2, 0, 'Use a keyfile (2)'),
                                                (3, 0, 'Use both (3)'))
            elif self.state == 2:
                if c == ord('n'):
                    self.lock_db()
                else:
                    self.pre_save()
                    self.lock_db()
            elif self.state > 2 and c in move_states:
                move_states[c]()
                if ((self.cur_win == 0 and
                     old_g_highlight != self.g_highlight) or
                    old_window != self.cur_win or
                    c == NL):
                    self.control.show_groups(self.g_highlight, self.groups,
                                             self.cur_win, self.g_offset,
                                             self.changed, self.cur_root)
                self.control.show_entries(self.e_highlight, self.entries,
                                          self.cur_win, self.e_offset)
def db_browser ( self ) : unlocked_state = { cur . KEY_F1 : self . control . dbbrowser_help , ord ( 'e' ) : self . exit2main , ord ( 'q' ) : self . quit_kpc , 4 : self . quit_kpc , ord ( 'c' ) : self . copy_password , ord ( 'b' ) : self . copy_username , ord ( 'o' ) : self . open_url , ord ( 's' ) : self . pre_save , ord ( 'S' ) : self . pre_save_as , ord ( 'x' ) : self . save_n_quit , ord ( 'L' ) : self . pre_lock , ord ( 'P' ) : self . change_db_password , ord ( 'g' ) : self . create_group , ord ( 'G' ) : self . create_sub_group , ord ( 'y' ) : self . create_entry , ord ( 'd' ) : self . pre_delete , ord ( 'f' ) : self . find_entries , ord ( '/' ) : self . find_entries , ord ( 't' ) : self . edit_title , ord ( 'u' ) : self . edit_username , ord ( 'U' ) : self . edit_url , ord ( 'C' ) : self . edit_comment , ord ( 'p' ) : self . edit_password , ord ( 'E' ) : self . edit_date , ord ( 'H' ) : self . show_password , ord ( 'm' ) : self . move , cur . KEY_RESIZE : self . control . resize_all , NL : self . go2sub , cur . KEY_BACKSPACE : self . go2parent , DEL : self . go2parent , cur . KEY_DOWN : self . nav_down , ord ( 'j' ) : self . nav_down , cur . KEY_UP : self . nav_up , ord ( 'k' ) : self . nav_up , cur . KEY_LEFT : self . nav_left , ord ( 'h' ) : self . nav_left , cur . KEY_RIGHT : self . nav_right , ord ( 'l' ) : self . nav_right , ord ( 'r' ) : self . reload_remote_db } locked_state = { ord ( 'q' ) : self . quit_kpc , 4 : self . quit_kpc , cur . KEY_DOWN : self . nav_down_lock , ord ( 'j' ) : self . nav_down_lock , cur . KEY_UP : self . nav_up_lock , ord ( 'k' ) : self . nav_up_lock , NL : self . unlock_db , ord ( '1' ) : self . unlock_with_password , ord ( '2' ) : self . unlock_with_keyfile , ord ( '3' ) : self . unlock_with_both } move_states = { ord ( 'e' ) : self . exit2main , ord ( 'q' ) : self . quit_kpc , 4 : self . quit_kpc , cur . KEY_DOWN : self . nav_down , ord ( 'j' ) : self . nav_down , cur . KEY_UP : self . nav_up , ord ( 'k' ) : self . nav_up , cur . KEY_LEFT : self . go2parent , ord ( 'h' ) : self . go2parent , cur . KEY_RIGHT : self . go2sub , ord ( 'l' ) : self . go2sub , NL : self . move_group_or_entry , cur . KEY_BACKSPACE : self . move2root , DEL : self . move2root , ESC : self . move_abort , cur . KEY_F1 : self . control . move_help } exceptions = ( ord ( 's' ) , ord ( 'S' ) , ord ( 'P' ) , ord ( 't' ) , ord ( 'p' ) , ord ( 'u' ) , ord ( 'U' ) , ord ( 'C' ) , ord ( 'E' ) , ord ( 'H' ) , ord ( 'g' ) , ord ( 'd' ) , ord ( 'y' ) , ord ( 'f' ) , ord ( '/' ) , cur . KEY_F1 , cur . KEY_RESIZE ) while True : old_g_highlight = self . g_highlight old_e_highlight = self . e_highlight old_window = self . cur_win old_root = self . cur_root if ( self . control . config [ 'lock_db' ] and self . state == 0 and self . db . filepath is not None ) : self . lock_timer = threading . Timer ( self . control . config [ 'lock_delay' ] , self . pre_lock ) self . lock_timer . start ( ) try : c = self . control . stdscr . getch ( ) except KeyboardInterrupt : c = 4 if type ( self . lock_timer ) is threading . Timer : self . lock_timer . cancel ( ) if self . state == 0 : if c == ord ( '\t' ) : # Switch group/entry view with tab. if self . cur_win == 0 : c = cur . KEY_RIGHT else : c = cur . KEY_LEFT if c in unlocked_state : unlocked_state [ c ] ( ) if c == ord ( 'e' ) : return False # 'cause 'L' changes state if self . state == 0 or self . state == 4 : if ( ( self . cur_win == 0 and old_g_highlight != self . g_highlight ) or c in exceptions or old_window != self . cur_win or old_root is not self . cur_root ) : self . control . show_groups ( self . g_highlight , self . groups , self . cur_win , self . g_offset , self . changed , self . cur_root ) if ( ( self . cur_win == 1 and old_e_highlight != self . e_highlight ) or c in exceptions or old_window != self . cur_win or old_g_highlight != self . g_highlight or old_root is not self . cur_root ) : self . control . show_entries ( self . e_highlight , self . entries , self . cur_win , self . e_offset ) elif self . state == 1 and c in locked_state : locked_state [ c ] ( ) if self . state == 1 : # 'cause 'L' changes state self . control . draw_lock_menu ( self . changed , self . lock_highlight , ( 1 , 0 , 'Use a password (1)' ) , ( 2 , 0 , 'Use a keyfile (2)' ) , ( 3 , 0 , 'Use both (3)' ) ) elif self . state == 2 : if c == ord ( 'n' ) : self . lock_db ( ) else : self . pre_save ( ) self . lock_db ( ) elif self . state > 2 and c in move_states : move_states [ c ] ( ) if ( ( self . cur_win == 0 and old_g_highlight != self . g_highlight ) or old_window != self . cur_win or c == NL ) : self . control . show_groups ( self . g_highlight , self . groups , self . cur_win , self . g_offset , self . changed , self . cur_root ) self . control . show_entries ( self . e_highlight , self . entries , self . cur_win , self . e_offset )