def update_req(name, old_req, config={}):
    """
    Takes a requirement and updates it based on a specific attribute key

    args:
        name: the name of the attribute
        old_req: the requirement definition
    """
    if not name:
        return old_req
    new_req = copy.deepcopy(old_req)
    del_idxs = []
    if "req_items" in old_req:
        req_key = get_req_key(old_req['req_items'])
        for i, item in enumerate(old_req['req_items']):
            if name == item[req_key] and item.get("dict_params"):
                for param, value in item['dict_params'].items():
                    new_req['item_dict'][param].update(value)
            if item.get("remove_if"):
                test_val = get_attr(config, item['remove_if']['attr'])
                if test_val == item['remove_if']['value']:
                    del_idxs.append(i)
        for idx in sorted(del_idxs, reverse=True):
            del new_req['req_items'][idx]

    return new_req
def update_req ( name , old_req , config = { } ) : if not name : return old_req new_req = copy . deepcopy ( old_req ) del_idxs = [ ] if "req_items" in old_req : req_key = get_req_key ( old_req [ 'req_items' ] ) for i , item in enumerate ( old_req [ 'req_items' ] ) : if name == item [ req_key ] and item . get ( "dict_params" ) : for param , value in item [ 'dict_params' ] . items ( ) : new_req [ 'item_dict' ] [ param ] . update ( value ) if item . get ( "remove_if" ) : test_val = get_attr ( config , item [ 'remove_if' ] [ 'attr' ] ) if test_val == item [ 'remove_if' ] [ 'value' ] : del_idxs . append ( i ) for idx in sorted ( del_idxs , reverse = True ) : del new_req [ 'req_items' ] [ idx ] return new_req
Takes a requirement and updates it based on a specific attribute key

    args:
        name: the name of the attribute
        old_req: the requirement definition