Skip to content

Commit

Permalink
Misc rule fixes (#291)
Browse files Browse the repository at this point in the history
  • Loading branch information
jziolkowski authored Sep 27, 2024
1 parent fa68be7 commit 2cb4357
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions tdmgr/GUI/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def __init__(self, device: TasmotaDevice, *args, **kwargs):
# RuleTimers
self.lwRTs = QListWidget()
self.lwRTs.setAlternatingRowColors(True)
self.lwRTs.addItems([f"RuleTimer{1}: <unknown>" for i in range(1, 9)])
self.lwRTs.addItems([f"RuleTimer{i}: <unknown>" for i in range(1, 9)])
self.lwRTs.clicked.connect(self.select_rt)
self.lwRTs.doubleClicked.connect(self.set_rt)

Expand Down Expand Up @@ -262,12 +262,9 @@ def display_rule(self, payload, rule):
self.actStopOnError.setChecked(payload["StopOnError"] == "ON")

def unfold_rule(self, rules: str):
return (
rules.replace(" on ", "\non ")
.replace(" do ", " do\n\t")
.replace(" endon", "\nendon ")
.rstrip(" ")
)
for pat, repl in [(r' on ', '\non '), (r' do ', ' do\n\t'), (r' endon', '\nendon ')]:
rules = re.sub(pat, repl, rules, flags=re.IGNORECASE)
return rules.rstrip(" ")

@pyqtSlot(Message)
def parseMessage(self, msg: Message):
Expand Down

0 comments on commit 2cb4357

Please sign in to comment.