aboutsummaryrefslogtreecommitdiff
blob: fedb505e1e21786162a2c34f65b060ae5174bf76 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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"])
Powered by cgit v1.2.3 (git 2.41.0)