File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change 2020)
2121
2222ATTR_NAME_REGEX = re .compile (r'[^.\[\]]+(?![^\[]*\])' )
23+ EXPR_STR_FORMAT_REGEX = re .compile (r"\{(\d+)\}" )
2324
2425
2526class ConditionBase :
@@ -60,6 +61,14 @@ def __eq__(self, other):
6061 def __ne__ (self , other ):
6162 return not self .__eq__ (other )
6263
64+ def __str__ (self ) -> str :
65+ format_str = EXPR_STR_FORMAT_REGEX .sub (
66+ r"{values[\1]}" , self .expression_format
67+ )
68+ return format_str .format (
69+ values = self ._values , operator = self .expression_operator
70+ )
71+
6372
6473class AttributeBase :
6574 def __init__ (self , name ):
@@ -133,6 +142,9 @@ def __eq__(self, other):
133142 def __ne__ (self , other ):
134143 return not self .__eq__ (other )
135144
145+ def __str__ (self ) -> str :
146+ return self .name
147+
136148
137149class ConditionAttributeBase (ConditionBase , AttributeBase ):
138150 """This base class is for conditions that can have attribute methods.
You can’t perform that action at this time.
0 commit comments