aboutsummaryrefslogtreecommitdiff
path: root/lib/python/milc.py
diff options
context:
space:
mode:
authorErovia <erovia@users.noreply.github.com>2019-11-24 20:24:47 +0100
committerskullydazed <skullydazed@users.noreply.github.com>2020-01-19 21:29:36 -0800
commit20290a1cffc074ae41a550fa6468cb2ed1dd3027 (patch)
tree67ef21616ee56b042889dff8ef813fc1b545c91e /lib/python/milc.py
parent80d329bb554f69630cda0376a51314698ad0ccdd (diff)
downloadqmk_firmware-20290a1cffc074ae41a550fa6468cb2ed1dd3027.tar.gz
qmk_firmware-20290a1cffc074ae41a550fa6468cb2ed1dd3027.zip
MILC: Fix/complete attribute heritance
If an undefined attribute of a submodule is accessed, fall back to same attribute of the submodule's parent.
Diffstat (limited to 'lib/python/milc.py')
-rw-r--r--lib/python/milc.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/python/milc.py b/lib/python/milc.py
index 4392c8376..92b1278f4 100644
--- a/lib/python/milc.py
+++ b/lib/python/milc.py
@@ -178,8 +178,9 @@ class ConfigurationSection(Configuration):
178 178
179 def __getitem__(self, key): 179 def __getitem__(self, key):
180 """Returns a config value, pulling from the `user` section as a fallback. 180 """Returns a config value, pulling from the `user` section as a fallback.
181 This is called when the attribute is accessed either via the get method or through [ ] index.
181 """ 182 """
182 if key in self._config: 183 if key in self._config and self._config[key]:
183 return self._config[key] 184 return self._config[key]
184 185
185 elif key in self.parent.user: 186 elif key in self.parent.user:
@@ -187,6 +188,15 @@ class ConfigurationSection(Configuration):
187 188
188 return None 189 return None
189 190
191 def __getattr__(self, key):
192 """Returns the config value from the `user` section.
193 This is called when the attribute is accessed via dot notation but does not exists.
194 """
195 if key in self.parent.user:
196 return self.parent.user[key]
197
198 return None
199
190 200
191def handle_store_boolean(self, *args, **kwargs): 201def handle_store_boolean(self, *args, **kwargs):
192 """Does the add_argument for action='store_boolean'. 202 """Does the add_argument for action='store_boolean'.
@@ -519,7 +529,10 @@ class MILC(object):
519 self.config[section][argument] = arg_value 529 self.config[section][argument] = arg_value
520 else: 530 else:
521 if argument not in self.config[section]: 531 if argument not in self.config[section]:
522 self.config[section][argument] = getattr(self.args, argument) 532 # Check if the argument exist for this section
533 arg = getattr(self.args, argument)
534 if arg:
535 self.config[section][argument] = arg
523 536
524 self.release_lock() 537 self.release_lock()
525 538