(self)
Create a group in the current root
Create a group in the current root
Create a group in the current root
def create_group(self):
        '''Create a group in the current root'''

        edit = Editor(self.control.stdscr, max_text_size=1, win_location=(0, 1),
                      win_size=(1, 80), title="Group Name: ")()
        if edit == -1:
            self.close()
        elif edit is not False:
            if self.groups:
                old_group = self.groups[self.g_highlight]
            else:
                old_group = None

            if self.remote is True:
                if self.cur_root is self.db.root_group:
                    root = 0
                else:
                    root = self.cur_root.id_
                db_buf = self.client().create_group(edit.encode(), 
                                                    str(root).encode())
                if self.check_answer(db_buf) is not False:
                    self.reload_remote_db(db_buf)
            else:
                try:
                    if self.cur_root is self.db.root_group:
                        self.db.create_group(edit)
                    else:
                        self.db.create_group(edit, self.cur_root)
                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:
                    self.changed = True

                self.sort_tables(True, True)
                if (self.groups and
                    self.groups[self.g_highlight] is not old_group and
                        old_group is not None):
                    self.g_highlight = self.groups.index(old_group)
def create_group ( self ) : edit = Editor ( self . control . stdscr , max_text_size = 1 , win_location = ( 0 , 1 ) , win_size = ( 1 , 80 ) , title = "Group Name: " ) ( ) if edit == - 1 : self . close ( ) elif edit is not False : if self . groups : old_group = self . groups [ self . g_highlight ] else : old_group = None if self . remote is True : if self . cur_root is self . db . root_group : root = 0 else : root = self . cur_root . id_ db_buf = self . client ( ) . create_group ( edit . encode ( ) , str ( root ) . encode ( ) ) if self . check_answer ( db_buf ) is not False : self . reload_remote_db ( db_buf ) else : try : if self . cur_root is self . db . root_group : self . db . create_group ( edit ) else : self . db . create_group ( edit , self . cur_root ) 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 : self . changed = True self . sort_tables ( True , True ) if ( self . groups and self . groups [ self . g_highlight ] is not old_group and old_group is not None ) : self . g_highlight = self . groups . index ( old_group )