blob: fedb505e1e21786162a2c34f65b060ae5174bf76 (
plain) (
tree)
|
|
import dbm
db = None
store_file = "fsq_poi.db"
def get_loc(fsq_id):
global db
if db is None:
db = dbm.open(store_file, 'c')
if fsq_id in db:
res = db[fsq_id].decode("utf-8").split("|")
return {
"name": res[0],
"locality": res[1],
"region": res[2],
"latitude": res[3],
"longitude": res[4],
"osm_url": res[5],
}
else:
return None
def store_loc(loc):
global db
if db is None:
db = dbm.open(store_file, 'c')
db[loc["fsq_id"]] = "{}|{}|{}|{}|{}|{}".format(loc["name"],
loc["locality"],
loc["region"],
loc["latitude"],
loc["longitude"],
loc["osm_url"])
|