]>
git.immae.eu Git - perso/Immae/Projets/Python/MusicSampler.git/blob - helpers/__init__.py
1 # -*- coding: utf-8 -*-
3 from .music_file
import *
6 draw_lock
= threading
.RLock()
8 def parse_config(mapping
):
10 stream
= open("config.yml", "r")
11 config
= yaml
.load(stream
)
14 aliases
= config
['aliases']
17 file_lock
= threading
.RLock()
19 for mapped_key
in config
['keys']:
20 key
= mapping
.find_by_unicode(mapped_key
)
24 for action
in config
['keys'][mapped_key
]:
25 action_name
= list(action
)[0]
27 if action
[action_name
] is None:
28 action
[action_name
] = []
30 if 'include' in action
[action_name
]:
31 included
= action
[action_name
]['include']
32 del(action
[action_name
]['include'])
34 if isinstance(included
, str):
35 action
[action_name
].update(aliases
[included
], **action
[action_name
])
37 for included_
in included
:
38 action
[action_name
].update(aliases
[included_
], **action
[action_name
])
40 for argument
in action
[action_name
]:
41 if argument
== 'file':
42 filename
= action
[action_name
]['file']
43 if filename
not in seen_files
:
44 seen_files
[filename
] = MusicFile(filename
, file_lock
)
46 action_args
['music'] = seen_files
[filename
]
49 action_args
[argument
] = action
[action_name
][argument
]
51 key
.add_action(action_name
, **action_args
)