1
0
Fork 0
mirror of synced 2024-11-04 16:28:56 -05:00

Fix Runtime dictionary modifications

This commit is contained in:
Ben Klein 2018-05-24 10:34:48 -04:00
parent 1abdd1e456
commit 15c8e8c12d

View file

@ -21,16 +21,16 @@ class Link(dotbot.Plugin):
if directive != self._directive: if directive != self._directive:
raise ValueError('Link cannot handle directive %s' % directive) raise ValueError('Link cannot handle directive %s' % directive)
data_filtered = copy.deepcopy(data) data_filtered = copy.deepcopy(data)
for destination, config in data_filtered.items(): for d_key in list(data_filtered):
if isinstance(config, dict) and self._config_if_key in config: if isinstance(data_filtered[d_key], dict) and self._config_if_key in data_filtered[d_key]:
self._log.debug("testing conditional: %s" % config[self._config_if_key]) self._log.debug("testing conditional: %s" % data_filtered[d_key][self._config_if_key])
commandsuccess = self._test_success(config[self._config_if_key]) commandsuccess = self._test_success(data_filtered[d_key][self._config_if_key])
if commandsuccess: if commandsuccess:
# command successful, treat as normal link # command successful, treat as normal link
del data_filtered[destination][self._config_if_key] del data_filtered[d_key][self._config_if_key]
else: else:
# remove the item from data, we aren't going to link it # remove the item from data, we aren't going to link it
del data_filtered[destination] del data_filtered[d_key]
return self._process_links(data_filtered) return self._process_links(data_filtered)