summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bvggrabber/api/scheduleddeparture.py16
-rw-r--r--bvggrabber/utils/__init__.py0
-rw-r--r--bvggrabber/utils/format.py7
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)