-
Notifications
You must be signed in to change notification settings - Fork 1
/
referential.py
37 lines (26 loc) · 922 Bytes
/
referential.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
33
34
35
36
37
import logging
class Referential:
def __init__(self):
self.logger = logging.getLogger(__name__)
self.instruments = []
def __cmp__(self, other):
return self.__dict__ == other.__dict__
def __eq__(self, other):
return self.__dict__ == other.__dict__
def __iter__(self):
return self
def __next__(self):
for instrument in self.instruments:
yield instrument
def next(self):
for instrument in self.instruments:
yield instrument
def __str__(self):
return '\n'.join([str(instrument) for instrument in self.instruments])
def __len__(self):
return len(self.instruments)
def add_instrument(self, instrument):
self.logger.debug('Adding [{}] to referential'.format(instrument))
self.instruments.append(instrument)
def get_instruments(self):
return self.instruments