Skip to content

Commit

Permalink
Handle key already present
Browse files Browse the repository at this point in the history
  • Loading branch information
droberts2013 committed May 23, 2019
1 parent 5c1016e commit 555cfe9
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/main/resources/xlr_xldeploy/XLDeployClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,12 +478,18 @@ def get_deployed_applications_for_environment(self, environment, date=None):
del deployed_apps[task['metadata']['application']]
return deployed_apps

def add_or_update_entry(self, entries, key, value):
for entry in entries:
if entry.tag == "entry" and entry.attrib["key"] == key:
entry.text = value
return
newentry = ET.Element('entry', key=key)
newentry.text =value
entries.insert(0, newentry)

def add_entry_to_dictionary(self, dictionary_id, key, value):
dictionary_xml = self.get_ci(dictionary_id, "xml")
root = ET.fromstring(dictionary_xml)
entries = root.find('entries')
newentry = ET.Element('entry', key=key)
newentry.text = value
entries.insert(0, newentry)
self.add_or_update_entry(entries, key, value)
self.update_ci(dictionary_id, ET.tostring(root), "xml")

0 comments on commit 555cfe9

Please sign in to comment.