mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-08-06 10:31:42 +00:00
Refactor of caching & data storage part 3 #118
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import csv
|
||||
|
||||
from data.sig_ref import SIGRef
|
||||
from sigrefdataproviders.local_file_sig_ref_data_provider import LocalFileSIGRefDataProvider
|
||||
|
||||
|
||||
class TOTA(LocalFileSIGRefDataProvider):
|
||||
"""SIG ref data provider for Toilets on the Air"""
|
||||
|
||||
SIG = "TOTA"
|
||||
PATH = "datafiles/tota.csv"
|
||||
|
||||
def __init__(self, provider_config):
|
||||
super().__init__(self.SIG, provider_config, self.PATH)
|
||||
|
||||
def _file_to_data(self, path):
|
||||
new_data = {}
|
||||
f = open(path)
|
||||
csv_data = f.read()
|
||||
dr = csv.DictReader(csv_data.splitlines())
|
||||
for row in dr:
|
||||
new_data[row["ref"]] = SIGRef(sig=self.SIG, id=row["ref"], name=row["ref"], latitude=float(row["lat"]),
|
||||
longitude=float(row["lon"]))
|
||||
return new_data
|
||||
Reference in New Issue
Block a user