summaryrefslogtreecommitdiff
path: root/ircbus.py
diff options
context:
space:
mode:
authorCormac Morris <cormacmorris@hotmail.com>2015-11-13 11:44:58 +0000
committerCormac Morris <cormacmorris@hotmail.com>2015-11-13 11:44:58 +0000
commitab7f0dac0ad052fc84290af79065bd7fb826ba35 (patch)
tree4c37325ba060e3a4d7eedad6334a2494fb4e74f9 /ircbus.py
parent22d1aecb11f48838e8f61122b15da82ca6df7eb7 (diff)
Updated script to supports buses that use letters and numbers together. Also added support forHEADmaster
using more than one word to search bus stop name.
Diffstat (limited to 'ircbus.py')
-rw-r--r--ircbus.py22
1 files changed, 12 insertions, 10 deletions
diff --git a/ircbus.py b/ircbus.py
index bd947cb..559e932 100644
--- a/ircbus.py
+++ b/ircbus.py
@@ -11,14 +11,13 @@ def split(s):
return filter(None, re.split(r'(\d+)', s))
ircinput = sys.stdin.read().lower()
-input = split(ircinput)
-stop = input[0].strip()
-bus = input[1].strip()
-bound = input[2].strip()
-busfile = bus + '.txt'
+input = ircinput.split()
+stop = re.split('[\s][(\d)x]', ircinput)[0]
+bus = input[-2].strip()
+bound = input[-1].strip()
+busfile = bus.upper() + '.txt'
now = datetime.now()
today = now.strftime("%A").lower()
-boundsearch = (bound + " - " + today)
datelist = []
if bound == "inbound":
@@ -26,9 +25,14 @@ if bound == "inbound":
else:
endbound = "inbound"
-if now.isoweekday() in range(1, 6):
- today = "monday-friday"
+if now.isoweekday() in range(1, 5):
+ day = "monday-friday"
+elif now.isoweekday() == 6:
+ day = "saturday"
+else:
+ day = "sunday"
+boundsearch = (bound + " - " + day)
with open(busfile, "r") as busread:
for line in busread:
line = line.lower()
@@ -40,8 +44,6 @@ with open(busfile, "r") as busread:
previousline = line.strip()
break
for line in busread:
- break
- for line in busread:
line = line.strip()
if ":" in line:
date = datetime.strptime(line, "%H:%M").time()