This repository was archived by the owner on Oct 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathroute.py
More file actions
85 lines (70 loc) · 2.88 KB
/
route.py
File metadata and controls
85 lines (70 loc) · 2.88 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
from datetime import date, datetime, timedelta
from stations import stations
from utils import rangers_is_at_home
from math import floor
import random
from colorama import Fore, Back, Style
from colorama import init as colorama_init
colorama_init()
def random_pub_name():
starts = ["Nag's", "Queen's", "Vicar's", "King's", "Barmaid's", "Jester's", "Bird's", "Lion's"]
ends = ["Arms", "Legs", "Head", "Tail", "Knackers", "Knees"]
return "The {whos} {what}".format(whos=random.choice(starts), what=random.choice(ends))
def route():
warnings = []
# we want to go inner
stations.reverse()
for s in stations:
s["correct_type"] = True if random.randint(1,10) > 5 else False
if not s["correct_type"]:
warnings.append({
"color": Fore.MAGENTA,
"msg": "Could not find a {venue_type} in {station}. Defaulted to {default}".format(
venue_type = random.choice(["Strip Club", "Bistro", "Gastro", "Gay Bar", "Cocktail Bar"]),
station = s["name"],
default = random.choice(["Pub", "Dive Bar"])
)
})
# timings for stops
time_per_stop = timedelta(minutes=42)
travel_time = timedelta(minutes=10)
today = date.today()
crawl_start = datetime(today.year, today.month, today.day, 12, 00)
current_crawl_time = crawl_start
# Get Ibrox tae fuck if Rangers is playing
at_home = rangers_is_at_home()
if at_home:
warnings.append({
"color": Fore.RED,
"msg": "# Rangers is playing at home at {kickoff}. Make sure you leave Ibrox by {start}".format(
kickoff=at_home["kickoff"].time(),
start=at_home["start"].time()
)})
planned_route = stations[4:] + stations[:4]
else:
planned_route = stations[1:] + stations[:1]
if len(warnings) > 0:
print(Back.GREEN + Fore.WHITE + "-- Notices:" + Fore.RESET + Back.RESET)
for warning in warnings:
print(warning["color"] + warning["msg"] + Fore.RESET)
print(Back.GREEN + Fore.WHITE + "-- Route:" + Fore.RESET + Back.RESET)
index = 1
for s in planned_route:
rating = random.randint(1,5)
print "#{i} - {station} - {pub} {rating}".format(
i=index,
station=s["name"],
pub=random_pub_name(),
rating="*" * rating
)
spaces = " " * int(floor(index / 10) + 1)
start_time = current_crawl_time
end_time = current_crawl_time + time_per_stop - travel_time
print " {spacing} be there for {start} and leave by {end}".format(
spacing=spaces,
start=Style.BRIGHT + str(start_time.time()) + Style.RESET_ALL,
end=Style.BRIGHT + str(end_time.time()) + Style.RESET_ALL
)
current_crawl_time = current_crawl_time + time_per_stop
index += 1
route()