From 8d21c1b9507b09f16028c427666f6465f7c9486f Mon Sep 17 00:00:00 2001 From: MaanuelMM Date: Tue, 26 Feb 2019 17:09:58 +0100 Subject: [PATCH] Add copy of request template on emt_madrid to avoid modify the original template --- bot.py | 6 +++--- emt_madrid.py | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/bot.py b/bot.py index 1d3c014..0222dfa 100644 --- a/bot.py +++ b/bot.py @@ -3,7 +3,7 @@ # Authors: MaanuelMM # Credits: eternnoir, atlink, CoreDumped-ETSISI, Eldinnie # Created: 2019/02/14 -# Last update: 2019/02/24 +# Last update: 2019/02/26 import os import telebot @@ -56,9 +56,9 @@ def process_time_left(time_left): elif(time_left > 1200): return ">20:00min" else: - return " " + str(int(time_left / 60)).zfill(2) + ":" + str(int(time_left % 60)).zfill(2) + "min" + return " " + str(int(time_left / 60)).zfill(2) + ":" + str(int(time_left % 60)).zfill(2) + "min" else: - return " --:--min" + return " --:--min" # https://stackoverflow.com/questions/4391697/find-the-index-of-a-dict-within-a-list-by-matching-the-dicts-value def sort_arrivals(arrivals): diff --git a/emt_madrid.py b/emt_madrid.py index 15a2acf..781922c 100644 --- a/emt_madrid.py +++ b/emt_madrid.py @@ -3,7 +3,7 @@ # Authors: MaanuelMM # Credits: EMT-Madrid, alvaroreig # Created: 2019/02/22 -# Last update: 2019/02/23 +# Last update: 2019/02/26 import requests @@ -11,7 +11,8 @@ def get_response(url, request_data): return requests.request("POST", url, data=request_data).json() # Return in JSON format -def get_arrive_stop(base_url, relative_url, request_data, id_client, pass_key, id_stop): +def get_arrive_stop(base_url, relative_url, request_data_template, id_client, pass_key, id_stop): + request_data = request_data_template.copy() # We only edit the copy, not the template url = base_url + relative_url request_data["idClient"] = id_client request_data["passKey"] = pass_key