def __init__(self, user_name, key, token): self.key = key self.token = token self.user_name = user_name self.org_api = Organizations(key, token) self.board_api = Boards(key, token) self.list_api = Lists(key, token) self.card_api = Cards(key, token) self.member_api = Members(key, token)
async def on_ready(self): # Access API access information in Creds.ini config = configparser.ConfigParser() config.read("Creds.ini") # How to reference the Trello board global board global b_id # How to reference a list on the Trello board global c_list # How to reference a card on the Trello board global cards board = Boards(config.get('trello', 'api_key'), config.get('trello', 'token')) b_id = config.get('trello', 'board_id') c_list = Lists(config.get('trello', 'api_key'), config.get('trello', 'token')) cards = Cards(config.get('trello', 'api_key'), config.get('trello', 'token')) print("Trello online.")
from trello import Boards from trello import Members import unicodedata def norm(dataunicode): return unicodedata.normalize('NFKD', dataunicode).encode('ascii', 'ignore') KEY = '5869b53180c8e5a19ae1e9a9d2d94916' TOKEN = 'a6c38225f99c5e4cf6ad8c4fc8149a1af77552c0d3f54cf367089f2255d451b3' BOARD_ID = '5af5977d264baece554c3fec' # DESENV membros = Members(KEY, TOKEN) boards = Boards(KEY, TOKEN) cards = boards.get_card(BOARD_ID) cabecalho = 'nome_tarefa' + ';' + 'responsavel' + ';' + 'labels' + ';' + 'data' + ';' + 'feito' print(cabecalho) for i in cards: if len(i[u'idMembers']) > 0: dono = membros.get(i[u'idMembers'][0]) nome_dono = dono[u'username'] else: nome_dono = 'Sem dono' lista_labels = '' if len(i[u'labels']) > 0: for j in i[u'labels']: lista_labels = lista_labels + '|' + j[u'name'] if i[u'due']: data = '' + i[u'due']
def get_cards(borad_id): board = Boards(TRELLO_APP_KEY, TRELLO_APP_TOKEN) cards = board.get_card(borad_id, filter={'closed'}) return cards
"id"] # ID of the board we're working on print( "Copy and paste the following link in your web browser to get a new token." ) print( trello.get_token_url("Similar Label Detector", expires="30days", write_access=True)) # visit site to get 64-character token # token given by website auth_token = "744be46a0777522b10e26f42a819274dcbdc490bfc6d927960dc555d0fdb94b7" trello.set_token(auth_token) cards = Cards(app_key, auth_token) boards = Boards(app_key, auth_token) cardIds = [] # empty list where we will store card ID's label_names = [] # empty list where we will store unmodified label names label_names_lc = [] # empty list where we will store lowercase label names print( "\nList of cards, their respective ID's, and their respective label names:" ) for x in range(0, len(boards.get_card(boardId))): # 0 to 9, because 10 cards y = boards.get_card(boardId)[x] # get every individual card's info card = y["name"] # get card's description card_id = y["shortLink"] # get card's ID # exception handling: some cards have no label whatsoever, so the "name" key doesn't exist in the "label section" try:
import sys from trello import TrelloApi from trello import Boards from trello import Actions from trello import Lists def add_card(tlist, name, description=None): try: lists = Lists(trello_key, trello_token) list_id = tlist[0]['id'] print(list_id) print(lists.new_card) card = lists.new_card(list_id,name, due="3/19/2021",desc=description) return card except Exception as e: print(f" error {e}") raise trello_key='9f4dbd353b6f9d815ff76bce29fb3ffa' trello_secret = 'cf0c804e47bbb38dc4c57369727b605c974caa68ee95bde67a2eb0210f9391f7' trello_token = '77850847cbd43e62004e89b0714b2885c3595c5cd73edeb44ad29cccf076b8db' boards = Boards(trello_key,trello_token) list = boards.get_list("20wnIRuI") print(list) card = add_card(list,"Remote Access","Remote access is test")