Skip to content

Commit

Permalink
Added __contains__ to threadlist
Browse files Browse the repository at this point in the history
This patch adds the __contains__ to the APRSDThreadList
class so we can do things like

if name in APRSDThreadList:
  # do something
  • Loading branch information
hemna committed Nov 27, 2024
1 parent d4ae726 commit d94a3e7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions aprsd/threads/aprsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit d94a3e7

Please sign in to comment.