Skip to content

Commit 555cfe9

Browse files
author
droberts2013
committed
Handle key already present
1 parent 5c1016e commit 555cfe9

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/main/resources/xlr_xldeploy/XLDeployClient.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -478,12 +478,18 @@ def get_deployed_applications_for_environment(self, environment, date=None):
478478
del deployed_apps[task['metadata']['application']]
479479
return deployed_apps
480480

481+
def add_or_update_entry(self, entries, key, value):
482+
for entry in entries:
483+
if entry.tag == "entry" and entry.attrib["key"] == key:
484+
entry.text = value
485+
return
486+
newentry = ET.Element('entry', key=key)
487+
newentry.text =value
488+
entries.insert(0, newentry)
489+
481490
def add_entry_to_dictionary(self, dictionary_id, key, value):
482491
dictionary_xml = self.get_ci(dictionary_id, "xml")
483492
root = ET.fromstring(dictionary_xml)
484493
entries = root.find('entries')
485-
newentry = ET.Element('entry', key=key)
486-
newentry.text = value
487-
entries.insert(0, newentry)
494+
self.add_or_update_entry(entries, key, value)
488495
self.update_ci(dictionary_id, ET.tostring(root), "xml")
489-

0 commit comments

Comments
 (0)