Skip to content

Commit

Permalink
Xml string reversing
Browse files Browse the repository at this point in the history
Signed-off-by: freedisch <[email protected]>
  • Loading branch information
Freedisch committed Jan 26, 2024
1 parent 1f2649f commit cc4c6fc
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
28 changes: 28 additions & 0 deletions aimodel/isFalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,34 @@ def json_to_xml(json_data, parent):
else:
parent.text = str(json_data)

#HEAVY REVERSE ENGINEERING SOLUTION TO READ DATA AND FORMAT DATA FROM XML FILES #PROUD_of_THAT
def reverst_data():
with open('output.xml', 'r') as file:
data_xml = file.read()

# Extract the name from the data XML
data = json.loads(ET.fromstring(data_xml).text)[0]
name = data['name']
print(data, name)

with open('response.xml', 'r') as file:
response_xml = file.read()

# Replace the placeholder with the extracted name
response_tree = ET.fromstring(response_xml)
say_element = response_tree.find('.//Say')
if say_element is not None:
say_element.text = say_element.text.replace('Friend', name)

# Save the modified XML
# with open('response.xml', 'w') as file:
# file.write(ET.tostring(response_tree).decode('utf-8'))
output_xml = ET.tostring(response_tree, encoding='utf-8').decode('utf-8')
output_xml = '<?xml version="1.0" encoding="UTF-8"?>\n' + output_xml

with open('response.xml', 'w') as file:
file.write(output_xml)



@app.route('/call')
Expand Down
8 changes: 8 additions & 0 deletions aimodel/response.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Say>This is SafetyCall reaching out to you with an urgent notification concerning your wubeshet. It appears that they may be experiencing a panic attack and are currently on the ground. We are taking immediate action to send you their current location for prompt assistance.

Your swift attention to this matter is crucial. Kindly ensure you act promptly and take appropriate measures to assist your friend. If you have any questions or require further information, please do not hesitate to contact us.

Thank you for your cooperation.</Say>
</Response>

0 comments on commit cc4c6fc

Please sign in to comment.