import datetime
import os

from alice_check_train.main import rasp_to_text
from alice_check_train.rasp_api import get_rasp, filter_rasp


def main():
    key = os.getenv('RASP_KEY')
    station_from = os.getenv('STATION_FROM')
    station_to = os.getenv('STATION_TO')
    date = datetime.date.today().strftime('%Y-%m-%d')

    js = get_rasp(key, station_from, station_to, date)
    filtered = filter_rasp(js['segments'], 300)
    message = rasp_to_text(filtered, 1000)
    if len(message) > 1024:
        print('Too long message: {} > 1024'.format(len(message)))
    print(message)


if __name__ == '__main__':
    main()

[((9, 10, 9, 31), 'os.getenv', 'os.getenv', ({(9, 20, 9, 30): '"""RASP_KEY"""'}, {}), "('RASP_KEY')", False, 'import os\n'), ((10, 19, 10, 44), 'os.getenv', 'os.getenv', ({(10, 29, 10, 43): '"""STATION_FROM"""'}, {}), "('STATION_FROM')", False, 'import os\n'), ((11, 17, 11, 40), 'os.getenv', 'os.getenv', ({(11, 27, 11, 39): '"""STATION_TO"""'}, {}), "('STATION_TO')", False, 'import os\n'), ((14, 9, 14, 54), 'alice_check_train.rasp_api.get_rasp', 'get_rasp', ({(14, 18, 14, 21): 'key', (14, 23, 14, 35): 'station_from', (14, 37, 14, 47): 'station_to', (14, 49, 14, 53): 'date'}, {}), '(key, station_from, station_to, date)', False, 'from alice_check_train.rasp_api import get_rasp, filter_rasp\n'), ((15, 15, 15, 47), 'alice_check_train.rasp_api.filter_rasp', 'filter_rasp', ({(15, 27, 15, 41): "js['segments']", (15, 43, 15, 46): '300'}, {}), "(js['segments'], 300)", False, 'from alice_check_train.rasp_api import get_rasp, filter_rasp\n'), ((16, 14, 16, 42), 'alice_check_train.main.rasp_to_text', 'rasp_to_text', ({(16, 27, 16, 35): 'filtered', (16, 37, 16, 41): '1000'}, {}), '(filtered, 1000)', False, 'from alice_check_train.main import rasp_to_text\n'), ((12, 11, 12, 32), 'datetime.date.today', 'datetime.date.today', ({}, {}), '()', False, 'import datetime\n')]