[Tutorial][Trello][API] How to create boards with lists.

For organizational purposes I imported the trello library and wrote up a bunch of functions. They’re all simple enough to make me wonder if it was a unnecessary:

#!python

import trello

def get_lists(board, board_id):
    return(board.get_list(board_id))

def create_a_board(board_object, board_name):
    return(board_object.new(board_name))

def create_a_list(board_object, board_id, list_name):
    return(board_object.new_list(board_id, list_name))

def get_org_id(url, length):
    return(url[length:])

This is where the trello Board object is created:

a = trello.Boards("key","token")

Create a lists of lists on the board:

board_lists ={}
for list in get_lists(a, "_id_"):
    board_lists[list['name']] = list

From the list of lists on a board, create a board for each list:

new_boards = {}
for board in board_lists:
    new_boards[board] = create_a_board(a, board)

For each newly created board, use the list of newly created boards create a list on the new boards from the list of “default” lists. One additional list is added, which is the list named after the board itself:

new_lists = {}
for board in new_boards:
    default_lists = [board, "Backlog", "In Progress", "Coding Done","QA", "Final QA", "QA Approved", "Prod Deployed"]
    default_lists.reverse()
    org_id = get_org_id (new_boards[board]['shortUrl'], 21)

    for i in default_lists:
        new_lists[i] = create_a_list(a,org_id, i)
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s