def main(args):
    if ((args is not None) and hasattr(args, 'file_groups')):
        file_groups = args.file_groups
        if is_str(file_groups):
            file_content = read_file(file_groups)
            category = file_content['category']
            category_name = category['name']
            groups = category['groups']
            if (hasattr(args, 'dbdriver') and hasattr(args, 'dbserver') and hasattr(args, 'dbuser') and hasattr(args, 'dbpassword')):
                db_server = args.dbserver
                db_user = args.dbuser
                db_pwd = args.dbpassword
                db_driver = args.dbdriver
                if (is_str(db_driver) and is_str(db_server) and is_str(db_user) and is_str(db_pwd)):
                    conn = connect_to_db(db_driver, db_server, db_user, db_pwd, DB)
                    if is_conn(conn):
                        category_type_id = check_category_type_by_name(conn, category_name)
                        clean_old_data(conn, category_type_id)
                        for group in groups:
                            category_id = insert_new_categories(conn, category_type_id, group)
                            if (('query_ids' in group) and ('name' in group) and ('severity_id' in group)):
                                severity_id = group['severity_id']
                                group_name = group['name']
                                queries = get_queries(conn, group['query_ids'])
                                print(group_name, ':', len(queries), 'queries to change')
                                insert_queries(conn, category_id, severity_id, queries)
                                update_category_severity_mapping(conn, severity_id, category_name, group_name)
                            else:
                                print('Group has 1 missing attribute: name                                    query_ids or severity_id')
                    else:
                        raise Exception('Cannot connect to Database')
                else:
                    raise Exception('db_server | db_user | db_pwd                             are not valid strings')
            else:
                raise Exception('db_server | db_user | db_pwd                         was not provided as an argument')
        else:
            raise TypeError('file_groups is not a string')
    else:
        raise AttributeError('args does not has file_groups as attribute')
def main(args):
    if ((args is not None) and hasattr(args, 'file_groups')):
        file_groups = args.file_groups
        if is_str(file_groups):
            file_content = read_file(file_groups)
            category = file_content['category']
            category_name = category['name']
            groups = category['groups']
            if (hasattr(args, 'dbdriver') and hasattr(args, 'dbserver') and hasattr(args, 'dbuser') and hasattr(args, 'dbpassword')):
                db_server = args.dbserver
                db_user = args.dbuser
                db_pwd = args.dbpassword
                db_driver = args.dbdriver
                if (is_str(db_driver) and is_str(db_server) and is_str(db_user) and is_str(db_pwd)):
                    conn = connect_to_db(db_driver, db_server, db_user, db_pwd, DB)
                    if is_conn(conn):
                        category_type_id = check_category_type_by_name(conn, category_name)
                        clean_old_data(conn, category_type_id)
                        for group in groups:
                            category_id = insert_new_categories(conn, category_type_id, group)
                            if (('query_ids' in group) and ('name' in group) and ('severity_id' in group)):
                                severity_id = group['severity_id']
                                group_name = group['name']
                                queries = get_queries(conn, group['query_ids'])
                                print(group_name, ':', len(queries), 'queries to change')
                                insert_queries(conn, category_id, severity_id, queries)
                                update_category_severity_mapping(conn, severity_id, category_name, group_name)
                            else:
                                print('Group has 1 missing attribute: name                                    query_ids or severity_id')
                    else:
                        raise Exception('Cannot connect to Database')
                else:
                    raise Exception('db_server | db_user | db_pwd                             are not valid strings')
            else:
                raise Exception('db_server | db_user | db_pwd                         was not provided as an argument')
        else:
            raise TypeError('file_groups is not a string')
    else:
        raise AttributeError('args does not has file_groups as attribute')