-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinsert.py
60 lines (48 loc) · 1.57 KB
/
insert.py
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
## hood - collective neighborhood opinion map generator
##Copyright (C) 2005 Matt Chisholm & Ross Cohen
##This program is free software; you can redistribute it and/or
##modify it under the terms of the GNU General Public License
##as published by the Free Software Foundation, version 2.
##This program is distributed in the hope that it will be useful,
##but WITHOUT ANY WARRANTY; without even the implied warranty of
##MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
##GNU General Public License for more details.
import sys
from hood import import db, geocoder
from config import config
if __name__ == '__main__':
geocoder.init(config)
print 'caution!'
#sys.exit()
test = False
if not test:
database = db.DB(config)
while 1:
try:
l = raw_input('location:> ')
l = l.lower()
except EOFError:
break
except KeyboardInterrupt:
break
try:
h = raw_input('neighborhood:> ')
except EOFError:
break
except KeyboardInterrupt:
break
latitude, longitude = geocoder.geocode(l)
if latitude is not None and longitude is not None:
print 'inserting', latitude, longitude, h
values = {
'loc' :l ,
'hood':h ,
'lat' :latitude ,
'long':longitude,
}
if not test:
database.insert_location(values)
else:
print 'fail'
if not test:
database.close_db()