Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
givanovexpe committed Oct 16, 2024
1 parent 83dcc4c commit 43fd06a
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions files/update_property.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,15 @@ def write_properties_to_xml(xml_path, property_name='', property_value='', appen
name = child.find("name").text.strip()
if name == property_name:
property_exists = True
current_value = child.find("value").text.strip()
value_element = child.find("value")

if value_element is None:
# If <value> does not exist, create it
value_element = ET.SubElement(child, "value")
current_value = ''
else:
current_value = value_element.text if value_element.text else ''
current_value = current_value.strip()

if append:
# Append the new value to the existing one, separated by commas
Expand All @@ -51,7 +59,7 @@ def write_properties_to_xml(xml_path, property_name='', property_value='', appen
else:
new_value = property_value

child.find("value").text = new_value
value_element.text = new_value
break

if not property_exists:
Expand All @@ -61,10 +69,11 @@ def write_properties_to_xml(xml_path, property_name='', property_value='', appen

xml.write(xml_path)
return 0
else:
else:
return -1



if __name__ == '__main__':
if len(sys.argv) > 1:
append_mode = '--append' in sys.argv # Check if '--append' is passed
Expand Down

0 comments on commit 43fd06a

Please sign in to comment.