forked from h4ck3rm1k3/codefortrenton-geocoder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
trello_geocode.py
executable file
·58 lines (51 loc) · 1.69 KB
/
trello_geocode.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
#!/usr/bin/python
import secrets
import sys
sys.path.append('../py-trello')
from trello import TrelloClient
import re
client = TrelloClient(
api_key=secrets.trello_key,
api_secret=secrets.trello_secret,
token=secrets.trello_oauth_token,
token_secret= secrets.trello_oauth_token_secret,
)
# https://github.com/opencagedata/python-opencage-geocoder
sys.path.append('./python-opencage-geocoder/')
import opencage
import opencage.geocoder
from secrets import opencage_key
geocoder = opencage.geocoder.OpenCageGeocode(opencage_key)
import parse_sms
import pprint
for b in client.list_boards():
#print b
for l in b.all_lists():
for c in l.list_cards():
comments = c.get_comments()
done = False
for cmt in comments :
#pprint.pprint(cmt)
txt = cmt['data']['text']
if 'GeoCode' in txt:
done = True
else:
#print ('Hmm' + txt)
pass
#print
if done :
print ("Done", c)
else:
print ("Todo",c)
g = re.search(r'Transcript:(.+)',c.description)
if g:
x = g.group(1)
for y in parse_sms.process(x):
# now we geocode this
gc = geocoder.geocode(y)
gc2 = pprint.pformat(gc)
c.comment("Identified Address: " + y)
c.comment("GeoCode: " + gc2)
done = True
if not done:
c.comment("GeoCode: Failed" )