From dc62736d843949a4f6a01cbd1af09c25a38673a9 Mon Sep 17 00:00:00 2001 From: Mark Powers Date: Mon, 19 Jul 2021 20:49:51 -0500 Subject: Refactor how some events work --- dial.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'dial.py') diff --git a/dial.py b/dial.py index 8fc92a9..d5117ff 100644 --- a/dial.py +++ b/dial.py @@ -58,18 +58,21 @@ class DialManager: self._load_sequences(phone_held, phone_hung_up) def _load_sequences(self, phone_held, phone_hung_up): - def recursive_add(classname, sequence_list, sequences): + def recursive_add(classname, sequence_list, sequences, args): key = int(sequence_list[0]) if not sequence_list[1:]: - sequences[key] = eval(classname)(self, phone_held, phone_hung_up) + sequences[key] = eval(classname)(self, phone_held, phone_hung_up, args) else: sequences[key] = {} - recursive_add(classname, sequence_list[1:], sequences[key]) + recursive_add(classname, sequence_list[1:], sequences[key], args) self.sequences = {} for sequence in config["sequences"]: print(sequence, config["sequences"][sequence], sep="\t") - recursive_add(config["sequences"][sequence], list(sequence), self.sequences) + parts = config["sequences"][sequence].split(" ", 1) + classname = parts[0] + args = parts[1:] + recursive_add(classname, list(sequence), self.sequences, args) def dial(self, number): if datetime.now() - self.update > timedelta(seconds=DIAL_RESET_TIME): -- cgit v1.2.3