X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=music_sampler%2Fmapping.py;fp=music_sampler%2Fmapping.py;h=50b68a9d903df95b0236cf76b4c39245628e9403;hb=dac64df84b0ed14199f41ac163d12ec20e497213;hp=e589ac0a93edfdb234587e25ab6cb1d15a4d7d1b;hpb=3a488f9facff1f0d3a9b943d7da318424bc35efb;p=perso%2FImmae%2FProjets%2FPython%2FMusicSampler.git 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): def parse_config(self): def update_alias(prop_hash, aliases, key): if isinstance(aliases[key], dict): - prop_hash.update(aliases[key], **prop_hash) + for alias in aliases[key]: + prop_hash.setdefault(alias, aliases[key][alias]) else: warn_print("Alias {} is not a hash, ignored".format(key)) @@ -336,6 +337,14 @@ class Mapping(RelativeLayout): seen_files = {} + common_key_properties = {} + if 'common' in config['key_properties'] and\ + isinstance(config['key_properties'], dict): + common_key_properties = config['key_properties']['common'] + include_aliases(common_key_properties, aliases) + elif 'common' in config['key_properties']: + warn_print("'common' key in key_properties is not a hash, ignored") + key_properties = defaultdict(lambda: { "actions": [], "properties": {}, @@ -343,6 +352,9 @@ class Mapping(RelativeLayout): }) for key in check_key_properties(config): + if key == 'common': + continue + key_prop = config['key_properties'][key] if not isinstance(key_prop, dict): @@ -351,6 +363,9 @@ class Mapping(RelativeLayout): continue include_aliases(key_prop, aliases) + for _key in common_key_properties: + key_prop.setdefault(_key, common_key_properties[_key]) + check_key_property(key_prop, key) key_properties[key]["properties"] = key_prop