diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2016-08-12 16:13:24 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2016-08-12 16:13:24 +0200 |
commit | 51f6ce0fdb32061b681d63e8de4d96eb8b59e1e9 (patch) | |
tree | ef684d10b4a97a73a1b0deab4b33b5f28d5deb39 /music_sampler | |
parent | 7df12958bed6544b36bc946cdbb185ff2011733c (diff) | |
download | MusicSampler-51f6ce0fdb32061b681d63e8de4d96eb8b59e1e9.tar.gz MusicSampler-51f6ce0fdb32061b681d63e8de4d96eb8b59e1e9.tar.zst MusicSampler-51f6ce0fdb32061b681d63e8de4d96eb8b59e1e9.zip |
Fix common key properties not applying when property is absent
Diffstat (limited to 'music_sampler')
-rw-r--r-- | music_sampler/mapping.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/music_sampler/mapping.py b/music_sampler/mapping.py index a04c2f6..99c9977 100644 --- a/music_sampler/mapping.py +++ b/music_sampler/mapping.py | |||
@@ -6,6 +6,7 @@ from kivy.clock import Clock | |||
6 | import threading | 6 | import threading |
7 | import yaml | 7 | import yaml |
8 | import sys | 8 | import sys |
9 | import copy | ||
9 | from collections import defaultdict | 10 | from collections import defaultdict |
10 | 11 | ||
11 | from transitions.extensions import HierarchicalMachine as Machine | 12 | from transitions.extensions import HierarchicalMachine as Machine |
@@ -355,12 +356,13 @@ class Mapping(RelativeLayout): | |||
355 | isinstance(config['key_properties'], dict): | 356 | isinstance(config['key_properties'], dict): |
356 | common_key_properties = config['key_properties']['common'] | 357 | common_key_properties = config['key_properties']['common'] |
357 | include_aliases(common_key_properties, aliases) | 358 | include_aliases(common_key_properties, aliases) |
359 | check_key_property(common_key_properties, 'common') | ||
358 | elif 'common' in config['key_properties']: | 360 | elif 'common' in config['key_properties']: |
359 | warn_print("'common' key in key_properties is not a hash, ignored") | 361 | warn_print("'common' key in key_properties is not a hash, ignored") |
360 | 362 | ||
361 | key_properties = defaultdict(lambda: { | 363 | key_properties = defaultdict(lambda: { |
362 | "actions": [], | 364 | "actions": [], |
363 | "properties": {}, | 365 | "properties": copy.deepcopy(common_key_properties), |
364 | "files": [] | 366 | "files": [] |
365 | }) | 367 | }) |
366 | 368 | ||
@@ -376,12 +378,9 @@ class Mapping(RelativeLayout): | |||
376 | continue | 378 | continue |
377 | 379 | ||
378 | include_aliases(key_prop, aliases) | 380 | include_aliases(key_prop, aliases) |
379 | for _key in common_key_properties: | ||
380 | key_prop.setdefault(_key, common_key_properties[_key]) | ||
381 | |||
382 | check_key_property(key_prop, key) | 381 | check_key_property(key_prop, key) |
383 | 382 | ||
384 | key_properties[key]["properties"] = key_prop | 383 | key_properties[key]["properties"].update(key_prop) |
385 | 384 | ||
386 | for mapped_key in check_mapped_keys(config): | 385 | for mapped_key in check_mapped_keys(config): |
387 | for index, action in enumerate(check_mapped_key( | 386 | for index, action in enumerate(check_mapped_key( |