Remove trailing whitespace (no code changes)
authorThomas Perl <m@thp.io>
Wed, 28 Sep 2011 18:38:37 +0000 (20:38 +0200)
committerThomas Perl <m@thp.io>
Wed, 28 Sep 2011 18:38:37 +0000 (20:38 +0200)
gotovienna/realtime.py
gotovienna/routing.py
itip
scotty

index ab4ba41..9565fd3 100644 (file)
@@ -18,22 +18,22 @@ class ITipParser:
         """
         if not self._stations.has_key(name):
             st = {}
-            
+
             if not self.lines.has_key(name):
                 return None
-            
+
             bs = BeautifulSoup(urlopen(self.lines[name]))
             tables = bs.findAll('table', {'class': 'text_10pix'})
             for i in range(2):
                 dir = tables[i].div.contents[-1].strip('&nbsp;')
-                
+
                 sta = []
                 for tr in tables[i].findAll('tr', {'onmouseout': 'obj_unhighlight(this);'}):
                     if tr.a:
                         sta.append((tr.a.text, settings.line_overview + tr.a['href']))
                     else:
                         sta.append((tr.text.strip('&nbsp;'), None))
-                    
+
                 st[dir] = sta
             self._stations[name] = st
 
@@ -47,7 +47,7 @@ class ITipParser:
             bs = BeautifulSoup(urlopen(settings.line_overview))
             # get tables
             lines = bs.findAll('td', {'class': 'linie'})
-            
+
             for line in lines:
                 if line.a:
                     href = settings.line_overview + line.a['href']
@@ -55,7 +55,7 @@ class ITipParser:
                         self._lines[line.text] = href
                     elif line.img:
                         self._lines[line.img['alt']] = href
-                        
+
         return self._lines
 
     def get_departures(self, url):
@@ -63,16 +63,16 @@ class ITipParser:
         integer if time until next departure
         time if time of next departure
         """
-        
+
         #TODO parse line name and direction for station site parsing
-        
+
         if not url:
             # FIXME prevent from calling this method with None
             return []
 
         bs = BeautifulSoup(urlopen(url))
         result_lines = bs.findAll('table')[-1].findAll('tr')
-        
+
         dep = []
         for tr in result_lines[1:]:
             th = tr.findAll('th')
@@ -80,15 +80,15 @@ class ITipParser:
                 #TODO replace with logger
                 print "[DEBUG] Unable to find th in:\n%s" % str(tr)
                 continue
-            
+
             # parse time
             time = th[-2].text.split(' ')
             if len(time) < 2:
                 print 'Invalid time: %s' % time
                 continue
-            
+
             time = time[1]
-            
+
             if time.find('rze...') >= 0:
                     dep.append(0)
             elif time.isdigit():
@@ -104,6 +104,6 @@ class ITipParser:
                     # Unexpected content
                     #TODO replace with logger
                     print "[DEBUG] Invalid data:\n%s" % time
-                
+
         return dep
 
index da89ba3..bb6cf96 100644 (file)
@@ -16,13 +16,13 @@ TIMEFORMAT = '%H:%M'
 DEBUGLOG = os.path.expanduser('~/gotoVienna.debug')
 
 class ParserError(Exception):
-    
+
     def __init__(self, msg='Parser error'):
         self.message = msg
 
 class PageType:
     UNKNOWN, CORRECTION, RESULT = range(3)
-    
+
 
 def search(origin_tuple, destination_tuple, dtime=None):
     """ build route request
@@ -30,13 +30,13 @@ def search(origin_tuple, destination_tuple, dtime=None):
     """
     if not dtime:
         dtime = datetime.now()
-    
+
     origin, origin_type = origin_tuple
     destination, destination_type = destination_tuple
     if not origin_type in POSITION_TYPES or\
         not destination_type in POSITION_TYPES:
         raise ParserError('Invalid position type')
-        
+
     post = settings.search_post
     post['name_origin'] = origin
     post['type_origin'] = origin_type
@@ -46,14 +46,14 @@ def search(origin_tuple, destination_tuple, dtime=None):
     post['itdTime'] = dtime.strftime('%H:%M')
     params = urlencode(post)
     url = '%s?%s' % (settings.action, params)
-    
+
     try:
         f = open(DEBUGLOG, 'a')
         f.write(url + '\n')
         f.close()
     except:
         print 'Unable to write to DEBUGLOG: %s' % DEBUGLOG
-    
+
     return urlopen(url)
 
 
@@ -63,23 +63,23 @@ class sParser:
 
     def __init__(self, html):
         self.soup = BeautifulSoup(html)
-    
+
     def check_page(self):
         if self.soup.find('form', {'id': 'form_efaresults'}):
             return PageType.RESULT
-        
+
         if self.soup.find('div', {'class':'form_error'}):
             return PageType.CORRECTION
-        
+
         return PageType.UNKNOWN
-    
+
     def get_correction(self):
         nlo = self.soup.find('select', {'id': 'nameList_origin'})
         nld = self.soup.find('select', {'id': 'nameList_destination'})
-        
+
         if not nlo and not nld:
             raise ParserError('Unable to parse html')
-        
+
         if nlo:
             origin = map(lambda x: x.text, nlo.findAll('option'))
         else:
@@ -88,14 +88,14 @@ class sParser:
             destination = map(lambda x: x.text, nld.findAll('option'))
         else:
             destination = []
-        
+
         return (origin, destination)
-    
+
     def get_result(self):
         return rParser(str(self.soup))
-        
-        
-        
+
+
+
 class rParser:
     """ Parser for routing results
     """
@@ -108,7 +108,7 @@ class rParser:
     @classmethod
     def get_tdtext(cls, x, cl):
             return x.find('td', {'class': cl}).text
-    
+
     @classmethod
     def get_change(cls, x):
         y = rParser.get_tdtext(x, 'col_change')
@@ -134,7 +134,7 @@ class rParser:
             return datetime.strptime(y, '%d.%m.%Y').date()
         else:
             return None
-        
+
     @classmethod
     def get_time(cls, x):
         y = rParser.get_tdtext(x, 'col_time')
@@ -145,7 +145,7 @@ class rParser:
                 return map(lambda z: time(*map(int, z.split(':'))), wrap(y, 5))
         else:
             return []
-        
+
     @classmethod
     def get_duration(cls, x):
         y = rParser.get_tdtext(x, 'col_duration')
@@ -177,7 +177,7 @@ class rParser:
         [ [ { 'time': [datetime.time, datetime.time] if time else [],
               'station': [u'start', u'end'] if station else [],
               'info': [u'start station' if station else u'details for walking', u'end station' if station else u'walking duration']
-            }, ... # next trip step 
+            }, ... # next trip step
           ], ... # next trip possibility
         ]
         """
@@ -195,7 +195,7 @@ class rParser:
         if table and table.findAll('tr'):
             # get rows
             rows = table.findAll('tr')[1:] # cut off headline
-            
+
             overview = map(lambda x: {
                                'date': rParser.get_date(x),
                                'time': rParser.get_time(x),
diff --git a/itip b/itip
index 7e352ee..b8fe1bf 100755 (executable)
--- a/itip
+++ b/itip
@@ -13,7 +13,7 @@ from gotovienna.realtime import ITipParser
 
 parser = argparse.ArgumentParser(description='Get realtime public transport information for Vienna')
 parser.add_argument('-l', metavar='name', type=str, help='line name')
-parser.add_argument('-s', metavar='name', type=str, help='station name')   
+parser.add_argument('-s', metavar='name', type=str, help='station name')
 
 args = parser.parse_args()
 
@@ -56,7 +56,7 @@ elif not l:
             type = 'Nightline'
         else:
             type = 'Andere'
-            
+
         line[type] += ' %s |' % li
     for kv in line.items():
         print "%s:\n%s" % kv
diff --git a/scotty b/scotty
index 6ea3ae3..4f88de1 100755 (executable)
--- a/scotty
+++ b/scotty
@@ -38,9 +38,9 @@ if state == PageType.CORRECTION:
                     print '%d. %s' % (i, c)
                     i += 1
                 lo = sys.stdin.readline().strip()
-            
+
             args.origin = cor[0][int(lo) - 1]
-            
+
         if cor[1]:
             print
             print '* Destination ambiguous:'
@@ -51,17 +51,17 @@ if state == PageType.CORRECTION:
                     print '%d. %s' % (j, c)
                     j += 1
                 ld = sys.stdin.readline().strip()
-                
+
             args.destination = cor[1][int(ld) - 1]
-        
+
         html = search((args.origin.encode('UTF-8'), args.ot), (args.destination.encode('UTF-8'), args.dt)).read()
 
         parser = sParser(html)
         state = parser.check_page()
-        
+
     except ParserError:
         print 'PANIC at correction page'
-        
+
 if state == PageType.RESULT:
     parser = rParser(html)
     try:
@@ -83,7 +83,7 @@ if state == PageType.RESULT:
             l = sys.stdin.readline().strip()
             print
             print '~' * 100
-            
+
             if l.isdigit() and int(l) <= len(details):
                 for detail in details[int(l) - 1]:
                     if detail['time'] and detail['station']:
@@ -93,9 +93,9 @@ if state == PageType.RESULT:
                         print '\n'.join(detail['info'])
                     print '-' * 100
             print
-            
+
     except ParserError:
         print 'parsererror'
-        
+
 elif state == PageType.UNKNOWN:
     print 'PANIC unknown result'