diff options
author | Christian Struck <christian@struck.se> | 2013-01-28 18:14:23 +0100 |
---|---|---|
committer | Christian Struck <christian@struck.se> | 2013-01-28 18:14:23 +0100 |
commit | 80cc719d353eb5ec511aeeef309218dea1d768a7 (patch) | |
tree | 51c1d7ea171c007381c81f868c882cd4d8a0418f | |
parent | 8c2de5d4a9802e43ceb7630e933655859aa80fe0 (diff) | |
download | bvg-grabber-80cc719d353eb5ec511aeeef309218dea1d768a7.tar.gz bvg-grabber-80cc719d353eb5ec511aeeef309218dea1d768a7.tar.bz2 bvg-grabber-80cc719d353eb5ec511aeeef309218dea1d768a7.zip |
Fixed a bug, where the Vehicle conversion did not work properly
-rw-r--r-- | bvggrabber/api/scheduleddeparture.py | 16 | ||||
-rw-r--r-- | bvggrabber/utils/__init__.py | 0 | ||||
-rw-r--r-- | bvggrabber/utils/format.py | 7 |
3 files changed, 16 insertions, 7 deletions
diff --git a/bvggrabber/api/scheduleddeparture.py b/bvggrabber/api/scheduleddeparture.py index 4531caa..4858d18 100644 --- a/bvggrabber/api/scheduleddeparture.py +++ b/bvggrabber/api/scheduleddeparture.py @@ -7,19 +7,21 @@ from bs4 import BeautifulSoup from bvggrabber.api import QueryApi, Departure, hourformat +from bvggrabber.utils.format import int2bin + SCHEDULED_QUERY_API_ENDPOINT = 'http://mobil.bvg.de/Fahrinfo/bin/stboard.bin/dox' class Vehicle(): - S = 1 - U = 2 - TRAM = 4 + S = 64 + U = 32 + TRAM = 16 BUS = 8 - FERRY = 16 - RB = 32 - IC = 64 + FERRY = 4 + RB = 2 + IC = 1 _ALL = 127 @@ -35,7 +37,7 @@ class ScheduledDepartureQueryApi(QueryApi): else: raise ValueError("Invalid type for station") self.station = station - self.vehicles = bin(vehicles)[2:] + self.vehicles = int2bin(vehicles) self.limit = limit def call(self): diff --git a/bvggrabber/utils/__init__.py b/bvggrabber/utils/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/bvggrabber/utils/__init__.py diff --git a/bvggrabber/utils/format.py b/bvggrabber/utils/format.py new file mode 100644 index 0000000..98bbaee --- /dev/null +++ b/bvggrabber/utils/format.py @@ -0,0 +1,7 @@ +#-*- coding: utf-8 -*- + +def int2bin(i, length): + + if not isinstance(length, int): + raise ValueError("expected int for length") + return ('{:0>' + str(length) + 'b}').format(i) |