-
Notifications
You must be signed in to change notification settings - Fork 0
/
Directory.py
33 lines (27 loc) · 859 Bytes
/
Directory.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
class Directory:
def __init__(self):
self.addresses = []
self.handles = []
def add_client(self, address, handle):
self.addresses.append(address)
self.handles.append(handle)
def remove_client(self, address=None, handle=None):
try:
if address or handle:
i = self.addresses.index(address) if address else self.handles.index(handle)
self.addresses.pop(i)
self.handles.pop(i)
except:
pass
def get_handle(self, address):
try:
i = self.addresses.index(address)
return self.handles[i]
except:
return None
def get_address(self, handle):
try:
i = self.handles.index(handle)
return self.addresses[i]
except:
return None