From f72905146899a87417c60bdccd7dcac3852a41c9 Mon Sep 17 00:00:00 2001
From: "Campos Cordobes, Sergio" <sergio.campos@tecnalia.com>
Date: Fri, 24 Mar 2023 12:52:15 +0100
Subject: [PATCH] Update configuration.py. getconfigurationfile returns a json,
 instead of xml

---
 src/configuration.py | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/src/configuration.py b/src/configuration.py
index 419e0f2..d1aea27 100644
--- a/src/configuration.py
+++ b/src/configuration.py
@@ -7,6 +7,11 @@ Created on: 16/01/2023
 """
 import math
 
+
+import json
+import xmltodict
+
+
 import sys
 print(sys.path)
 from src import constants, utils
@@ -102,21 +107,23 @@ def getconfigurationfile(cnx, request):
         city = request.args.get("city", default=None, type=str)
         if (city=="BIO"):
             fichero = open('kpis_bilbao.dex')
-            ret_json = fichero.read() 
+            ret_xml = fichero.read()
 
         if (city=="AMS"):
             fichero = open('kpis_amsterdam.dex')
-            ret_json = fichero.read()
-        
+            ret_xml = fichero.read()
+
         if (city=="HEL"):
             fichero = open('kpis_helsinki.dex')
-            ret_json = fichero.read()
-        
+            ret_xml = fichero.read()
+
         if (city=="MES"):
             fichero = open('kpis_messina.dex')
-            ret_json = fichero.read()
+            ret_xml = fichero.read()
+
+        data_dict = xmltodict.parse(ret_xml)
+        ret_json = json.dumps(data_dict)
 
-        return ret_json 
     except:
         return constants.ERROR_EXCEPTION
 
-- 
GitLab