def test_region(self): api = viaggiatreno.API() reg_code = self.api.call('regione', 'S00219') self.assertEqual(reg_code, 3)
16: "Puglia", 17: "Calabria", 18: "Campania", 19: "Abruzzo", 20: "Sardegna", 22: "Trentino Alto Adige" } destdir = os.path.join('data', 'stations-dump') if not os.path.exists(destdir): os.makedirs(destdir) as_csv = [] as_geojson = {'type': 'FeatureCollection', 'features': []} api = viaggiatreno.API() sortkey = itemgetter(0) num_stations = 0 for letter in string.ascii_uppercase: #Get all stations which name starts with 'letter' stations = api.call('autocompletaStazione', letter) num_stations += len(stations) print(letter, len(stations), num_stations) for s in sorted(stations, key=sortkey): station_name, station_id = s station = { 'name': station_name, 'id': station_id, 'region': 'N/A', 'region_code': 'N/A',
def setUp(self): self.api = viaggiatreno.API()