From 57df1771d1035357da17241d7ba685fed36b21e0 Mon Sep 17 00:00:00 2001 From: Florian Schweikert Date: Tue, 20 Sep 2011 17:17:50 +0200 Subject: [PATCH] =?utf8?q?[FIX]=20"In=20K=C3=BCrze"-Bug=20iTip=20cli=20can=20?= =?utf8?q?show=20all=20available=20lines?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- iTip.py | 33 ++++++++++++++++++++++++++++----- scotty.py | 4 ++++ 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/iTip.py b/iTip.py index afd1825..4b7aea4 100644 --- a/iTip.py +++ b/iTip.py @@ -3,6 +3,7 @@ from urllib2 import urlopen import settings from datetime import time import argparse +import re class iParser: @@ -83,7 +84,9 @@ class iParser: time = time[1] - if time.isdigit(): + if time.find('rze...') >= 0: + dep.append(0) + elif time.isdigit(): # if time to next departure in cell convert to int dep.append(int(time)) else: @@ -101,14 +104,17 @@ class iParser: if __name__ == '__main__': parser = argparse.ArgumentParser(description='Get realtime public transport information for Vienna') - parser.add_argument('-l', metavar='name', type=str, help='line name', required=True) + parser.add_argument('-l', metavar='name', type=str, help='line name') parser.add_argument('-s', metavar='name', type=str, help='station name') args = parser.parse_args() itip = iParser() lines = itip.lines - l = args.l.upper() + if args.l: + l = args.l.upper() + else: + l = None s = args.s if l and l in lines: @@ -124,5 +130,22 @@ if __name__ == '__main__': else: print ' %s' % station[0] - elif l: - print 'Line "%s" not found' % args.l + elif not l: + line = {'U-Bahn': '|', 'Strassenbahn': '|', 'Bus': '|', 'Andere': '|', 'Nightline': '|'} + lines_sorted = lines.keys() + lines_sorted.sort() + for li in lines_sorted: + if li.isdigit(): + type = 'Strassenbahn' + elif li.endswith('A') or li.endswith('B') and li[1].isdigit(): + type = 'Bus' + elif li.startswith('U'): + type = 'U-Bahn' + elif li.startswith('N'): + type = 'Nightline' + else: + type = 'Andere' + + line[type] += ' %s |' % li + for kv in line.items(): + print "%s:\n%s" % kv \ No newline at end of file diff --git a/scotty.py b/scotty.py index 6a6f564..80a26ec 100644 --- a/scotty.py +++ b/scotty.py @@ -4,6 +4,7 @@ from urllib import urlencode import settings from datetime import datetime, time from textwrap import wrap +import argparse POSITION_TYPES = ('stop', 'address', 'poi') @@ -207,3 +208,6 @@ class rParser: f.close() return self._overview + +if __name__ == '__main__': + pass \ No newline at end of file -- 1.7.9.5