(self)
Edit password of marked entry
Edit password of marked entry
Edit password of marked entry
def edit_password(self):
        '''Edit password of marked entry'''

        nav = self.control.gen_menu(1, ((1, 0, 'Use password generator (1)'),
                                     (2, 0, 'Type password by hand (2)'),
                                     (3, 0, 'No password (3)')))
        if nav == 1:
            password = self.control.gen_pass()
            if password == -1:
                self.close()
            elif password is False:
                return False
            if self.remote is True:
                uuid = self.entries[self.e_highlight].uuid
                last_mod = (self.entries[self.e_highlight]
                                .last_mod.timetuple())
                db_buf = self.client().set_e_pass(password.encode(),
                                                  uuid, last_mod)
                if self.check_answer(db_buf) is not False:
                    self.reload_remote_db(db_buf)
            else:
                self.entries[self.e_highlight].set_password(password)
                self.changed = True
        elif nav == 2:
            while True:
                password = self.control.get_password('Password: ', False)
                if password is False:
                    break
                elif password == -1:
                    self.close()
                confirm = self.control.get_password('Confirm: ', False)
                if confirm is False:
                    continue
                elif confirm == -1:
                    self.close()

                if password == confirm:
                    if self.remote is True:
                        uuid = self.entries[self.e_highlight].uuid
                        last_mod = (self.entries[self.e_highlight]
                                        .last_mod.timetuple())
                        db_buf = self.client().set_e_pass(password.encode(),
                                                          uuid, last_mod)
                        if self.check_answer(db_buf) is not False:
                            self.reload_remote_db(db_buf)
                    else:
                        self.entries[self.e_highlight].set_password(password)
                        self.changed = True
                    break
                else:
                    self.control.draw_text(self.changed,
                                           (3, 0, 'Passwords didn\'t match. '
                                               'Press any key.'))
                    if self.control.any_key() == -1:
                        self.close()
                    break
        elif nav == -1:
            self.close()
def edit_password ( self ) : nav = self . control . gen_menu ( 1 , ( ( 1 , 0 , 'Use password generator (1)' ) , ( 2 , 0 , 'Type password by hand (2)' ) , ( 3 , 0 , 'No password (3)' ) ) ) if nav == 1 : password = self . control . gen_pass ( ) if password == - 1 : self . close ( ) elif password is False : return False if self . remote is True : uuid = self . entries [ self . e_highlight ] . uuid last_mod = ( self . entries [ self . e_highlight ] . last_mod . timetuple ( ) ) db_buf = self . client ( ) . set_e_pass ( password . encode ( ) , uuid , last_mod ) if self . check_answer ( db_buf ) is not False : self . reload_remote_db ( db_buf ) else : self . entries [ self . e_highlight ] . set_password ( password ) self . changed = True elif nav == 2 : while True : password = self . control . get_password ( 'Password: ' , False ) if password is False : break elif password == - 1 : self . close ( ) confirm = self . control . get_password ( 'Confirm: ' , False ) if confirm is False : continue elif confirm == - 1 : self . close ( ) if password == confirm : if self . remote is True : uuid = self . entries [ self . e_highlight ] . uuid last_mod = ( self . entries [ self . e_highlight ] . last_mod . timetuple ( ) ) db_buf = self . client ( ) . set_e_pass ( password . encode ( ) , uuid , last_mod ) if self . check_answer ( db_buf ) is not False : self . reload_remote_db ( db_buf ) else : self . entries [ self . e_highlight ] . set_password ( password ) self . changed = True break else : self . control . draw_text ( self . changed , ( 3 , 0 , 'Passwords didn\'t match. ' 'Press any key.' ) ) if self . control . any_key ( ) == - 1 : self . close ( ) break elif nav == - 1 : self . close ( )