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()

[((160, 181), 'os.getenv', 'os.getenv', (['"""RASP_KEY"""'], {}), "('RASP_KEY')\n", (169, 181), False, 'import os\n'), ((201, 226), 'os.getenv', 'os.getenv', (['"""STATION_FROM"""'], {}), "('STATION_FROM')\n", (210, 226), False, 'import os\n'), ((244, 267), 'os.getenv', 'os.getenv', (['"""STATION_TO"""'], {}), "('STATION_TO')\n", (253, 267), False, 'import os\n'), ((332, 377), 'alice_check_train.rasp_api.get_rasp', 'get_rasp', (['key', 'station_from', 'station_to', 'date'], {}), '(key, station_from, station_to, date)\n', (340, 377), False, 'from alice_check_train.rasp_api import get_rasp, filter_rasp\n'), ((393, 425), 'alice_check_train.rasp_api.filter_rasp', 'filter_rasp', (["js['segments']", '(300)'], {}), "(js['segments'], 300)\n", (404, 425), False, 'from alice_check_train.rasp_api import get_rasp, filter_rasp\n'), ((440, 468), 'alice_check_train.main.rasp_to_text', 'rasp_to_text', (['filtered', '(1000)'], {}), '(filtered, 1000)\n', (452, 468), False, 'from alice_check_train.main import rasp_to_text\n'), ((279, 300), 'datetime.date.today', 'datetime.date.today', ([], {}), '()\n', (298, 300), False, 'import datetime\n')]