aboutsummaryrefslogtreecommitdiff
path: root/music_sampler/mapping.py
diff options
context:
space:
mode:
Diffstat (limited to 'music_sampler/mapping.py')
-rw-r--r--music_sampler/mapping.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/music_sampler/mapping.py b/music_sampler/mapping.py
index e589ac0..50b68a9 100644
--- a/music_sampler/mapping.py
+++ b/music_sampler/mapping.py
@@ -224,7 +224,8 @@ class Mapping(RelativeLayout):
224 def parse_config(self): 224 def parse_config(self):
225 def update_alias(prop_hash, aliases, key): 225 def update_alias(prop_hash, aliases, key):
226 if isinstance(aliases[key], dict): 226 if isinstance(aliases[key], dict):
227 prop_hash.update(aliases[key], **prop_hash) 227 for alias in aliases[key]:
228 prop_hash.setdefault(alias, aliases[key][alias])
228 else: 229 else:
229 warn_print("Alias {} is not a hash, ignored".format(key)) 230 warn_print("Alias {} is not a hash, ignored".format(key))
230 231
@@ -336,6 +337,14 @@ class Mapping(RelativeLayout):
336 337
337 seen_files = {} 338 seen_files = {}
338 339
340 common_key_properties = {}
341 if 'common' in config['key_properties'] and\
342 isinstance(config['key_properties'], dict):
343 common_key_properties = config['key_properties']['common']
344 include_aliases(common_key_properties, aliases)
345 elif 'common' in config['key_properties']:
346 warn_print("'common' key in key_properties is not a hash, ignored")
347
339 key_properties = defaultdict(lambda: { 348 key_properties = defaultdict(lambda: {
340 "actions": [], 349 "actions": [],
341 "properties": {}, 350 "properties": {},
@@ -343,6 +352,9 @@ class Mapping(RelativeLayout):
343 }) 352 })
344 353
345 for key in check_key_properties(config): 354 for key in check_key_properties(config):
355 if key == 'common':
356 continue
357
346 key_prop = config['key_properties'][key] 358 key_prop = config['key_properties'][key]
347 359
348 if not isinstance(key_prop, dict): 360 if not isinstance(key_prop, dict):
@@ -351,6 +363,9 @@ class Mapping(RelativeLayout):
351 continue 363 continue
352 364
353 include_aliases(key_prop, aliases) 365 include_aliases(key_prop, aliases)
366 for _key in common_key_properties:
367 key_prop.setdefault(_key, common_key_properties[_key])
368
354 check_key_property(key_prop, key) 369 check_key_property(key_prop, key)
355 370
356 key_properties[key]["properties"] = key_prop 371 key_properties[key]["properties"] = key_prop