From 8998a34b02f9013577b84bcc0e906f52668b6ce0 Mon Sep 17 00:00:00 2001 From: "julio.oliveira" Date: Fri, 26 Jan 2024 16:38:24 -0300 Subject: [PATCH] Addressed comments in the PR. --- netbox/extras/conditions.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/netbox/extras/conditions.py b/netbox/extras/conditions.py index 11098fe08..e8ba2bed9 100644 --- a/netbox/extras/conditions.py +++ b/netbox/extras/conditions.py @@ -134,15 +134,11 @@ class ConditionSet: if type(ruleset) is not dict: raise ValueError(f"Ruleset must be a dictionary, not {type(ruleset)}.") - self.logic = None - - # If logic type use it, else return the ruleset if len(ruleset) == 1: - logic = list(ruleset.keys())[0] - if logic not in (AND, OR): + self.logic = (list(ruleset.keys())[0]).lower() + if self.logic not in (AND, OR): raise ValueError( - f"Invalid logic type: {logic} (must be '{AND}' or '{OR}'). Please check documentation.") - self.logic = logic.lower() + f"Invalid logic type: {self.logic} (must be '{AND}' or '{OR}'). Please check documentation.") # Compile the set of Conditions self.conditions = [ @@ -151,6 +147,7 @@ class ConditionSet: ] else: try: + self.logic = None self.conditions = [Condition(**ruleset)] except TypeError: raise ValueError(f"Incorrect key(s) informed. Please check documentation.")