From d94a3e7b908fd313a8af0c71a4928114ea83cf35 Mon Sep 17 00:00:00 2001 From: Hemna Date: Wed, 27 Nov 2024 11:40:53 -0500 Subject: [PATCH] Added __contains__ to threadlist This patch adds the __contains__ to the APRSDThreadList class so we can do things like if name in APRSDThreadList: # do something --- aprsd/threads/aprsd.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/aprsd/threads/aprsd.py b/aprsd/threads/aprsd.py index 9176bd7a..a7415c75 100644 --- a/aprsd/threads/aprsd.py +++ b/aprsd/threads/aprsd.py @@ -88,6 +88,13 @@ def __new__(cls, *args, **kwargs): cls.threads_list = [] return cls._instance + def __contains__(self, name): + """See if we have a thread in our list""" + for t in self.threads_list: + if t.name == name: + return True + return False + def stats(self, serializable=False) -> dict: stats = {} for th in self.threads_list: