Merge branch 'master' into experimental
[pywienerlinien] / itip
diff --git a/itip b/itip
index 57c5b11..4af78b1 100755 (executable)
--- a/itip
+++ b/itip
@@ -3,17 +3,9 @@
 
 import argparse
 
+from gotovienna.utils import *
 from gotovienna.realtime import *
 
-def inred(x):
-    return '\033[91m' + x + '\033[0m'
-
-def ingreen(x):
-    return '\033[92m' + x + '\033[0m'
-
-def inblue(x):
-    return '\033[94m' + x + '\033[0m'
-
 parser = argparse.ArgumentParser(description='Get realtime public transport information for Vienna')
 parser.add_argument('line', nargs='?', help='line name (e.g. 59A)')
 parser.add_argument('station', nargs='?', help='station name (e.g. Karlsplatz)')
@@ -93,6 +85,24 @@ if args.line in itip.lines:
             print '  No departure information.'
         print
 else:
+    s = ''
+
+if l and l in lines:
+    stations = itip.get_stations(l)
+    for key in stations.keys():
+        if not s:
+            print '* %s:' % key
+        for station in stations[key]:
+            if s:
+                if s.startswith(station[0]) or station[0].startswith(s):
+                    if station[0] == key:
+                        # skip station if destination
+                        continue
+                    # FIXME
+                    print '* %s\n  %s .....' % (key, station[0]), itip.get_departures(station[1])
+            else:
+                print '    %s' % station[0]
+elif not l:
     ITEMS_PER_LINE = 12
     ITEM_WIDTH = 5
     LINE_WIDTH = (ITEMS_PER_LINE*ITEM_WIDTH + ITEMS_PER_LINE)