New utility function to replace an attribute

This commit is contained in:
Dion Moult
2020-08-04 21:08:49 +10:00
parent 2a22acfdc9
commit 6772886e65
@@ -51,3 +51,15 @@ def get_properties(properties):
del(data['HasProperties'])
results[prop.Name] = data
return results
def replace_attribute(element, old, new):
for i, attribute in enumerate(element):
if attribute == old:
element[i] = new
elif isinstance(attribute, tuple):
new_attribute = list(attribute)
for j, item in enumerate(attribute):
if item == old:
new_attribute[j] = new
element[i] = new_attribute