コード例 #1
0
ファイル: test_format.py プロジェクト: jgontrum/bvg-grabber
 def test_int2bin(self):
     nums = [(0b1101110, 7, '1101110'), (0b0010001, 7, '0010001'),
             (0b111111, 6, '111111'), (0b00000001, 8, '00000001'),
             (0b00111, 5, '00111'), (0b00111, 8, '00000111'),
             (0b1100011, 7, '1100011')]
     for b, l, s in nums:
         self.assertEqual(int2bin(b, l), s)
     self.assertRaises(ValueError, int2bin, 12, 'abc')
コード例 #2
0
ファイル: test_format.py プロジェクト: MarkusH/bvg-grabber
 def test_int2bin(self):
     nums = [(0b1101110, 7, '1101110'),
             (0b0010001, 7, '0010001'),
             (0b111111, 6, '111111'),
             (0b00000001, 8, '00000001'),
             (0b00111, 5, '00111'),
             (0b00111, 8, '00000111'),
             (0b1100011, 7, '1100011')]
     for b, l, s in nums:
         self.assertEqual(int2bin(b, l), s)
     self.assertRaises(ValueError, int2bin, 12, 'abc')
コード例 #3
0
 def __init__(self, station, vehicles=Vehicle._ALL, limit=5):
     """:param Vehicle vehicles: a bitmask described by :class:`Vehicle`"""
     super(ScheduledDepartureQueryApi, self).__init__()
     if isinstance(station, str):
         self.station_enc = station.encode('iso-8859-1')
     elif isinstance(station, bytes):
         self.station_enc = station
     else:
         raise ValueError("Invalid type for station")
     self.station = station
     self.vehicles = int2bin(vehicles, 7)
     self.limit = limit
コード例 #4
0
 def __init__(self, station, vehicles=Vehicle._ALL, limit=5):
     """:param Vehicle vehicles: a bitmask described by :class:`Vehicle`"""
     super(ScheduledDepartureQueryApi, self).__init__()
     if isinstance(station, str):
         self.station_enc = station.encode('iso-8859-1')
     elif isinstance(station, bytes):
         self.station_enc = station
     else:
         raise ValueError("Invalid type for station")
     self.station = station
     self.vehicles = int2bin(vehicles, 7)
     self.limit = limit