def chk_i_children(old, new, ctx): for oldch in old.i_children: chk_child(oldch, new, ctx) # chk_child removes all old children for newch in new.i_children: if statements.is_mandatory_node(newch): err_add(ctx.errors, newch.pos, 'CHK_NEW_MANDATORY', newch.arg)
def chk_i_children(old, new, ctx): for oldch in old.i_children: chk_child(oldch, new, ctx) old_child_args = [oldch.arg for oldch in old.i_children] added_new_children = [new_child for new_child in new.i_children if new_child.arg not in old_child_args] for newch in added_new_children: if statements.is_mandatory_node(newch): err_add(ctx.errors, newch.pos, 'CHK_NEW_MANDATORY', newch.arg)
def chk_if_feature(old, new, ctx): # make sure no if-features are removed if node is mandatory for s in old.search('if-feature'): if new.search_one('if-feature', arg=s.arg) is None: if statements.is_mandatory_node(new): err_def_removed(s, new, ctx) # make sure no if-features are added for s in new.search('if-feature'): if old.search_one('if-feature', arg=s.arg) is None: err_def_added(s, ctx)
def chk_if_feature(old, new, ctx): # make sure no if-features are removed if node is mandatory for s in old.search('if-feature'): if new.search_one('if-feature', arg=s.arg) is None: if statements.is_mandatory_node(new): err_def_removed(s, new, ctx) # make sure no if-features are added for s in new.search('if-feature'): if old.search_one('if-feature', arg=s.arg) is None: err_def_added2(s, new, ctx)
def chk_config(old, new, ctx): if old.i_config == False and new.i_config == True: if statements.is_mandatory_node(new): err_add(ctx.errors, new.pos, 'CHK_MANDATORY_CONFIG', new.arg) elif old.i_config == True and new.i_config == False: err_add(ctx.errors, new.pos, 'CHK_BAD_CONFIG', new.arg)
def v_chk_mandatory_top_level(ctx, stmt): for s in stmt.i_children: if statements.is_mandatory_node(s): err_add(ctx.errors, s.pos, 'LINT_TOP_MANDATORY', s.arg)