-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.py
More file actions
64 lines (56 loc) · 1.92 KB
/
cli.py
File metadata and controls
64 lines (56 loc) · 1.92 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import pickle
import click
from click_shell import shell
def run():
global our_dorm
with open('saved_step.pickle', 'rb') as f:
our_dorm = pickle.load(f)
f.close()
with open('saved_step_2.pickle', 'rb') as f:
our_dorm.set_room_list(pickle.load(f))
f.close()
our_dorm.find_all_students()
our_dorm.next_month()
our_dorm.define_is_kitchen_okey()
print(our_dorm.roach())
our_dorm.noise_in_dorm()
print(our_dorm.visit_every_room())
our_dorm.change_duty()
our_dorm.save_to_file()
our_dorm.print_field()
app()
@shell(prompt='> ', intro='Запуск CLI...')
def app():
pass
@app.command(help='Травить тараканов в комнате №[1..15]')
@click.argument('number')
def kill_roach(number):
try:
room = our_dorm.get_room_by_number(int(number))
print(room.kill_roach())
our_dorm.save_to_file()
except IndexError:
print('В общежитии 15 комнат')
@app.command(help='Вывести информацию о комнате №[1..15]')
@click.argument('number')
def print_info_room(number):
try:
room = our_dorm.get_room_by_number(int(number))
print(room.info())
except IndexError:
print('В общежитии 15 комнат')
@app.command(help='Заселить студента в комнату №[1..15]')
@click.argument('number')
def check_in(number):
try:
room = our_dorm.get_room_by_number(int(number))
print(our_dorm.check_in(room))
our_dorm.save_to_file()
except IndexError:
print('В общежитии 15 комнат')
@app.command()
def print_info_dorm():
print(our_dorm.info())
@app.command()
def print_map():
our_dorm.print_field()