-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconsole_interface.py
executable file
·50 lines (39 loc) · 1.12 KB
/
console_interface.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/python3.5
# -*- coding: utf-8 -*-
import click
import regiojet
from datetime import datetime
import pprint
@click.group()
def main():
'''
Aplikace pro vyhledávání spojení a rezervování míst
'''
return
@main.command()
@click.option('--from', 'from_', type=str)
@click.option('--to', 'to_', type=str)
@click.option('--date_from', 'date_from', type=str)
@click.option('--date_to', 'date_to', type=str)
def search(from_, to_, date_from, date_to):
'''
Vyhledávání spojení
'''
date_from = datetime.strptime(date_from, '%Y-%m-%d').date()
date_to = datetime.strptime(date_to, '%Y-%m-%d').date()
search_result = regiojet.search(from_, to_, date_from, date_to)
if search_result is None:
print('Nenalezeno')
return
for ticket in search_result:
# pp = pprint.PrettyPrinter(depth=6)
# pp.pprint(ticket)
print('{type:^10} {departure} - {arrival} {price:>15}Kč {free_seats:>5} volných míst'.format(**ticket))
@main.command()
def booking():
'''
Rezervace spojení
'''
print('booking')
if __name__ == '__main__':
main()