Skip to content

Commit

Permalink
[acl-loader] change helper functions to pop_*
Browse files Browse the repository at this point in the history
Signed-off-by: Stepan Blyschak <stepanb@mellanox.com>
  • Loading branch information
Stepan Blyschak committed Aug 7, 2019
1 parent 6cb194b commit ff512e3
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions acl_loader/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ def validate_actions(self, table_name, action_props):

if action_value not in capability[key]:
del action_props[action_key]
continue

return action_count == len(action_props)

Expand Down Expand Up @@ -667,11 +668,11 @@ def show_rule(self, table_name, rule_id):
"""
header = ("Table", "Rule", "Priority", "Action", "Match")

def show_priority(val):
def pop_priority(val):
priority = val.pop("PRIORITY")
return priority

def show_action(val):
def pop_action(val):
action = ""

for key in dict(val):
Expand All @@ -689,7 +690,7 @@ def show_action(val):

return action

def show_matches(val):
def pop_matches(val):
matches = list(sorted(["%s: %s" % (k, val[k]) for k in val]))
if len(matches) == 0:
matches.append("N/A")
Expand All @@ -704,9 +705,9 @@ def show_matches(val):
if rule_id and rule_id != rid:
continue

priority = show_priority(val)
action = show_action(val)
matches = show_matches(val)
priority = pop_priority(val)
action = pop_action(val)
matches = pop_matches(val)

rule_data = [[tname, rid, priority, action, matches[0]]]
if len(matches) > 1:
Expand Down

0 comments on commit ff512e3

Please sign in to comment.