Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

more parser fixes

  • Loading branch information...
commit a187e962a3c20e5173719354fac3de68af99719f 1 parent 7b130b7
@kelvan authored
Showing with 10 additions and 4 deletions.
  1. +6 −1 gotovienna-qml
  2. +4 −3 gotovienna/realtime.py
View
7 gotovienna-qml
@@ -63,6 +63,11 @@ class Config(QObject):
return check_stations_update()
except:
return False
+
+ @Slot(result=bool)
+ def clearCache(self):
+ print "TODO clear cache"
+ return True
class AboutInfo(QObject):
def __init__(self):
@@ -276,7 +281,6 @@ class Gui(QObject):
stations = get_nearby_stations(lat, lon)
print stations
for station in stations:
- print station
try:
self.current_departures += self.itip.get_departures_by_station(station)
except Exception as e:
@@ -306,6 +310,7 @@ class Gui(QObject):
return get_nearby_stations(lat, lon)
except BaseException as e:
# No/wrong stations.db file
+ print e.message
return []
View
7 gotovienna/realtime.py
@@ -18,7 +18,7 @@
from gotovienna import defaults
-DELTATIME_REGEX = re.compile('.*(\d+).*min.*')
+DELTATIME_REGEX = re.compile('.*(\d+).*')
ABSTIME_REGEX = re.compile('.*(\d{2}:\d{2}).*')
class Departure(dict):
@@ -192,14 +192,15 @@ def get_departures_by_station(self, station):
if li[0].a:
# calculate levenshtein distance of results
st = map(lambda x: (distance(station, x.a.text), x.a.text, x.a['href']), li)
+ print st
# take result with lowest levenshtein distance
lnk = min(st)[2]
+ print lnk
html = urlopen(defaults.qando + lnk).read()
dep = self.parse_departures_by_station(html)
- self.parse_departures_by_station(html)
return dep
def parse_departures(self, html):
@@ -240,7 +241,7 @@ def parse_departures(self, html):
if dts:
# is timedelta
- d['time'] = dts.group(1)
+ d['time'] = int(dts.group(1))
elif tim.isdigit():
d['time'] = int(tim)
elif abs:
Please sign in to comment.
Something went wrong with that request. Please try again.