Skip to content
This repository has been archived by the owner on Dec 29, 2019. It is now read-only.

Commit

Permalink
Add copy of request template on emt_madrid to avoid modify the origin…
Browse files Browse the repository at this point in the history
…al template
  • Loading branch information
MaanuelMM committed Mar 12, 2019
1 parent a9e31b0 commit 8d21c1b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down
5 changes: 3 additions & 2 deletions emt_madrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@
# Authors: MaanuelMM
# Credits: EMT-Madrid, alvaroreig
# Created: 2019/02/22
# Last update: 2019/02/23
# Last update: 2019/02/26

import requests


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
Expand Down

0 comments on commit 8d21c1b

Please sign in to comment.