blob: 101298d785276a974166c7b1bd277568b949460f (
plain)
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
38
39
|
from unipath import FSPath as Path
DATA_DIR = Path(__file__).absolute().ancestor(1).child('data')
class LightLoopClient(object):
def __init__(self):
self.sequences = {}
self.compostion = []
self.tempo = 300
self.init_data()
def __str__(self):
return '{}\n{}\n{}'.format(self.sequences, self.composition, self.tempo)
def init_data(self):
with open(DATA_DIR.child('data.txt'), 'r') as f:
data = f.read()
sequence_data, composition_data = data.split('\n===\n')
for sequence in sequence_data.split('#')[1:]:
lines = sequence.split('\n')
name, sequence_data = lines[0].strip(), [map(int, list(x)) for x in filter(lambda x: x != '', lines[1:])]
self.sequences[name] = sequence_data
self.composition = [c.split(',') for c in composition_data.split('\n')[1:]]
def process_single_loop(self):
for c in self.composition:
pass
def loop(self):
print self
if __name__ == '__main__':
client = LightLoopClient()
client.loop()
|