-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtrello_export.py
68 lines (53 loc) · 1.85 KB
/
trello_export.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
61
62
63
64
65
66
67
68
import os
import ConfigParser
import csv
import sys
import warnings
from trello import util as trello_util
import trello
from setup_trello_oauth import get_trello_config
def write_card_data():
# get the client to login
config = get_trello_config()
client = trello.TrelloClient(
api_key=config.get('trello', 'api_key'),
api_secret=config.get('trello', 'api_secret'),
token=config.get('trello', 'token'),
token_secret=config.get('trello', 'token_secret'),
)
# get the board associated with our sales pipeline
board = client.get_board(config.get('trello', 'pipeline_board'))
# set up our output writing
writer = csv.writer(sys.stdout)
writer.writerow([
# can get these directly from the API
'id', 'url', 'opportunity', 'first contact', 'last update',
# can infer this directly from the API
'company name', # from the card name
'outcome', # from the list name
# stuff we can fill in on our own?
'proposal cost',
'proposal timeline',
# stuff that Whitney can get for us
'client number of employees',
'approximate annual revenues',
'client wikipedia page (if exists)',
'client main contact (linkedin)',
])
# go through all of the lists to determine the outcome of different engagement
for l in board.open_lists():
for card in l.list_cards():
card.fetch()
sys.stderr.write("%s\n" % card.name)
writer.writerow([
card.id,
card.url,
card.name,
card.create_date,
card.date_last_activity,
card.name.split(':', 1)[0],
card.trello_list.name,
])
with warnings.catch_warnings():
warnings.simplefilter("ignore")
write_card_data()