def setUp(self): self.client = Client(api_key, user_auth_token) self.org = Organisation(self.client, organisation) self.board = Board(self.client, board_id) self.list = List(self.client, list_id) self.card = Card(self.client, card_id) self.checklist = Checklist(self.client, checklist_id) self.member = Member(self.client, member_id)
def test_token(client=None): try: b = Board(client, user.board_id) print b.getBoardInformation() return True except trolly.ResourceUnavailable: print "bad board id" return False except trolly.Unauthorised: print "bad permissions (refresh token)" return False
def set_board(client=None): board_id = raw_input("paste in id of board: ").strip() b = Board(client, board_id) try: print b.getBoardInformation() user.board_id = board_id return True except trolly.ResourceUnavailable: print "bad board id" return False except trolly.Unauthorised: print "bad permissions (refresh token)" return False
def get_cards(use_cache=False, client=None): """ Returns [name, id] of cards from cache if cache flag is True else returns from Trello and refreshes cache """ if use_cache: print use_cache, cache.cards return cache.cards print client, user.board_id if user.board_id is None: set_board() b = Board(client, user.board_id) cards = b.getCards() card_names_and_ids = [(unidecode(c.name.decode("utf8")), c.id) for c in cards] cache.cards = card_names_and_ids return card_names_and_ids
def create_board(self, board_json): """ Create Board object from a JSON object """ return Board(trello_client=self, board_id=board_json['id'], name=board_json['name'])
class TracHello(): def __init__(self): self.client = Client(api_key, user_auth_token) self.board = Board(self.client, board_id) def test_org_02_getBoards(self): result = self.board.getBoardInformation() print result
class TracHello(): def __init__( self ): self.client = Client( api_key, user_auth_token ) self.board = Board( self.client, board_id ) def test_org_02_getBoards( self ): result = self.board.getBoardInformation(); print result;
def createBoard( self, board_json ): """ Create Board object from a JSON object """ return Board( trello_client = self, board_id = board_json['id'].encode('utf-8'), name = board_json['name'].encode( 'utf-8' ) )
def get_list_obj(**kwargs): debug = kwargs['debug'] verbose = kwargs['verbose'] conn = kwargs['trelloConn'] board_id = kwargs['boardID'] list_name = kwargs['listName'] # Get the board boardObj = Board(conn, board_id) # Find the Done list ID for boardListObj in boardObj.getLists(): listDict = boardListObj.getListInformation() if (listDict['name'] == list_name): if (debug >= 1): print "Found %s as ID for list %s" % (listDict['id'], list_name) returnObj = boardListObj if (debug >= 2): print "%s : %s" % (listDict['id'], listDict['name']) return returnObj
def __init__(self, client, app, boardId, config): QtGui.QMainWindow.__init__(self) self.lists = [] self.app = app self.client = client self.boardId = boardId self.config = config self.trelloBoardStyle = self.config.get('TrelloBoard', 'style') self.board = Board(client, boardId) self.screen = QtGui.QDesktopWidget().screenGeometry() self.setMouseTracking(True) self.updatePointingMultiplier() self.style() self.show()
class Trello(BotPlugin): def __init__(self): #self.conn = TrelloConnection('3dd167f33e6de7d4f13fcd138346210c', 'ba57d7a637f46d664b8e30a0d8f50642c55c117dadf23cf7c699c51be5e36cbd') self.client = Client(api_key=os.getenv('TRELLO_APP_KEY'), user_auth_token=os.getenv('TRELLO_OAUTH_TOKEN')) self.board = Board(self.client, os.getenv('TRELLO_BOARD')) def kanban_walker(self): flow = reversed(self.board.get_lists()) for card_list in flow: for card in card_list.get_cards(): yield card @botcmd def top(self, _msg, _args): cards = itertools.islice(self.kanban_walker(), 5) return '\n'.join( [card.get_card_information()['name'] for card in cards]) @botcmd def hello(self, _msg, _args): return "Hello, world!"
def __init__(self, trelloClient, boardId): Board.__init__(self, trelloClient, boardId )
class TrelloTests(unittest.TestCase): def setUp(self): self.client = Client(api_key, user_auth_token) self.org = Organisation(self.client, organisation) self.board = Board(self.client, board_id) self.list = List(self.client, list_id) self.card = Card(self.client, card_id) self.checklist = Checklist(self.client, checklist_id) self.member = Member(self.client, member_id) def tearDown(self): pass def test_org_01_getOrgInfo(self): result = self.org.get_organisation_information() self.assertIsNotNone(result, 'JSON was empty') def test_org_02_getBoards(self): for board in self.org.get_boards(): self.assertIsNotNone(board.id, msg="ID has not been provided") self.assertIsNotNone(board.name, msg="Name has not been provided") def test_org_03_getMembers(self): for member in self.org.get_members(): self.assertIsNotNone(member.id, msg="ID has not been provided") self.assertIsNotNone(member.name, msg="Name has not been provided") def test_org_04_updateOrganisation(self): description = str(uuid.uuid1()) new_organisation = self.org.update_organisation({'desc': description}) new_description = new_organisation.get_organisation_information( )['desc'] self.assertEqual( description, new_description, msg="Descriptions don't match. Update Organisation didn't work!") def test_boa_01_getBoardInformation(self): result = self.board.get_board_information() self.assertIsNotNone(result, 'JSON was empty') def test_boa_02_getLists(self): for lis in self.board.get_lists(): self.assertIsNotNone(lis.id, msg="ID has not been provided") self.assertIsNotNone(lis.name, msg="Name has not been provided") def test_boa_03_getCards(self): for card in self.board.get_cards(): self.assertIsNotNone(card.id, msg="ID has not been provided") self.assertIsNotNone(card.name, msg="Name has not been provided") def test_boa_04_getCard(self): card = self.board.get_card(card_id) self.assertIsNotNone(card.id, msg="ID has not been provided") self.assertIsNotNone(card.name, msg="Name has not been provided") def test_boa_05_getMembers(self): for member in self.board.get_members(): self.assertIsNotNone(member.id, msg="ID has not been provided") self.assertIsNotNone(member.name, msg="Name has not been provided") def test_boa_06_getOrganisation(self): organisation = self.board.get_organisation() self.assertIsNotNone(organisation.id, msg="ID has not been provided") self.assertIsNotNone(organisation.name, msg="Name has not been provided") def test_boa_07_updateBoard(self): description = str(uuid.uuid1()) new_board = self.board.update_board({'desc': description}) new_description = new_board.get_board_information()['desc'] self.assertEqual( description, new_description, msg="Descriptions don't match. Update Board didn't work!") def test_boa_08_addList(self): name = str(uuid.uuid1()) new_list = self.board.add_list({'name': name}) new_list_name = new_list.name self.assertEqual(name, new_list_name, msg="Names don't match. Add list didn't work!") def test_lis_01_getListInformation(self): result = self.list.get_list_information() self.assertIsNotNone(result, 'JSON was empty') def test_lis_02_getBoard(self): board = self.list.get_board() self.assertIsNotNone(board.id, msg="ID has not been provided") self.assertIsNotNone(board.name, msg="Name has not been provided") def test_lis_03_getCards(self): for card in self.list.get_cards(): self.assertIsNotNone(card.id, msg="ID has not been provided") self.assertIsNotNone(card.name, msg="Name has not been provided") def test_lis_04_updateList(self): name = str(uuid.uuid1()) new_list = self.list.update_list({'name': name}) new_list_name = new_list.name self.assertEqual(name, new_list_name, msg="Names don't match. Update list didn't work!") def test_lis_05_addCard(self): name = str(uuid.uuid1()) new_card = self.list.add_card({'name': name}) new_card_name = new_card.name self.assertEqual(name, new_card_name, msg="Names don't match. Add card didn't work!") def test_car_01_getCardInformation(self): result = self.card.get_card_information() self.assertIsNotNone(result, 'JSON was empty') def test_car_02_getBoard(self): board = self.card.get_board() self.assertIsNotNone(board.id, msg="ID has not been provided") self.assertIsNotNone(board.name, msg="Name has not been provided") def test_car_03_getList(self): lis = self.card.get_list() self.assertIsNotNone(lis.id, msg="ID has not been provided") self.assertIsNotNone(lis.name, msg="Name has not been provided") def test_car_04_getChecklists(self): for checklist in self.card.get_checklists(): self.assertIsNotNone(checklist.id, msg="ID has not been provided") self.assertIsNotNone(checklist.name, msg="Name has not been provided") def test_car_05_getMembers(self): for member in self.card.get_members(): self.assertIsNotNone(member.id, msg="ID has not been provided") self.assertIsNotNone(member.name, msg="Name has not been provided") def test_car_06_updateCard(self): description = str(uuid.uuid1()) new_card = self.card.update_card({'desc': description}) new_description = new_card.getCardInformation()['desc'] self.assertEqual( description, new_description, msg="Descriptions don't match. Update Card didn't work!") def test_car_07_addComments(self): comment = str(uuid.uuid1()) result = self.card.add_comments(comment) new_comment = result['data']['text'] self.assertEqual(comment, new_comment, msg="Comments don't match. Add comment didn't work!") def test_car_08_addAttachment(self): f = open('test/test.txt', 'r').read() result = self.card.add_attachment('text.txt', f) self.assertIsNotNone(result, "Got nothing back, doesn't look like it worked!") def test_car_09_addChecklists(self): name = str(uuid.uuid1()) new_checklist = self.card.add_checklists({'name': name}) new_checklist_name = new_checklist.name self.assertEqual(name, new_checklist_name, "Names don't match. Add Checklist failed!") def test_car_10_addLabels(self): try: label_colour = 'green' result = self.card.add_labels({'value': label_colour}) found_label = False for label in result: if label['color'] == label_colour: found_label = True self.assertTrue(found_label, "Label wasn't added!") except ResourceUnavailable: # Label already added pass def test_car_11_addMember(self): try: result = self.card.add_member(member_id) found_member = False for member in result: if member.id == member_id: found_member = True self.assertTrue(found_member, "Member wasn't added to card!") except ResourceUnavailable: # Member is already on the card pass def test_car_12_removeMember(self): try: result = self.card.remove_member(member_id) self.assertIsNotNone(result, "JSON failure! Nothing was returned") for member in result: self.assertNotEqual(member['id'], member_id, "Member was not removed!") except ResourceUnavailable: # Member isn't attached to card pass def test_che_01_getChecklistInformation(self): result = self.checklist.get_checklist_information() self.assertIsNotNone(result, 'JSON was empty') def test_che_02_getItems(self): result = self.checklist.get_items() self.assertIsNotNone(result, 'JSON was empty') def test_che_03_updateChecklist(self): name = str(uuid.uuid1()) new_checklist = self.checklist.update_checklist(name) new_name = new_checklist.name self.assertEqual(name, new_name, msg="Names don't match. Update didn't work!") def test_che_04_addItem(self): name = str(uuid.uuid1()) result = self.checklist.add_item({'name': name}) new_item_name = result['name'] self.assertEqual(name, new_item_name, "Names don't match! Add item failed") def test_che_05_removeItem(self): items = self.checklist.get_items() if len(items) > 0: item_id = items[0]['id'] result = self.checklist.remove_item(item_id) self.assertIsNotNone(result, "JSON was empty!") def test_mem_01_getMemberInformation(self): result = self.member.get_member_information() self.assertIsNotNone(result, 'JSON was empty') def test_mem_02_getBoards(self): for board in self.member.get_boards(): self.assertIsNotNone(board.id, msg="ID has not been provided") self.assertIsNotNone(board.name, msg="Name has not been provided") def test_mem_03_getCards(self): for cards in self.member.get_cards(): self.assertIsNotNone(cards.id, msg="ID has not been provided") self.assertIsNotNone(cards.name, msg="Name has not been provided")
def manageActive(): changesMade= False client= Client(keys.api_key, keys.user_auth_token) # for each card in "Project Backlog" board: # if card is labeled "Active" (green): # record its original list & pos # mark the description with its origin project list name (if not "General") # move it to "This Week" list in "Active" board # for each card in "Active" board: # if card is in "Finished" or "Overview" list: # remove label "Active" (green) # else: # if card is not labeled "Active" (green): # move it back to its original list & pos (in "Project Backlog" board) # remove project mark in description # for each card in "Finished" list that has been archived: # move such cards to lists in the "Closed" board that correspond to their # origin project list in "Project Backlog" board, creating if needed, # then un-archive the card in its new position # ---------------------------------------------------------------------------- # for each card in "Project Backlog" board: backlogBoard= Board(client, keys.boardIds['backlog']) backlogCards= backlogBoard.getCardsJson(backlogBoard.base_uri) for card in backlogCards: # if card is labeled "Active" (green): labels= [i['color'] for i in card['labels']] if 'green' in labels: cardHandle= Card(client, card['id']) originDB[str(card['id'])]= (card['idList'], card['pos']) # mark its description with the project list name projectName= List(client, card['idList']).getListInformation()['name'] desc= markProjectInDesc(card['desc'], projectName) cardHandle.setDesc(desc) # move it to "This Week" list in "Active" board cardHandle.moveTo(keys.boardIds['active'], keys.listIds['this week']) # reset labels for l in labels: cardHandle.addLabel(l) changesMade= True # for each card in "Active" board: activeBoard= Board(client, keys.boardIds['active']) activeCards= activeBoard.getCardsJson(activeBoard.base_uri) for card in activeCards: labels= [i['color'] for i in card['labels']] # if card is in "Finished" list: if ((card['idList'] == keys.listIds['finished']) or (card['idList'] == keys.listIds['overview'])): # remove "Active" (green) labels cardHandle= Card(client, card['id']) if 'green' in labels: cardHandle.removeLabel('green') changesMade= True else: # if card is not labeled "Active" (green): if 'green' not in labels: cardHandle= Card(client, card['id']) ## if card was moved here from the backlog: #actions= cardHandle.getActions('moveCardToBoard')['actions'] #if ((len(actions) > 0) and # (actions[0]['data']['boardSource']['id'] == keys.boardIds['backlog'])): # if card has an origin project entry if (str(card['id']) in originDB): # remove project list name from its description desc= markProjectInDesc(card['desc'], None) cardHandle.setDesc(desc) # move it back to its original list & pos (in "Project Backlog" board) origin= originDB[str(card['id'])] cardHandle.moveTo(keys.boardIds['backlog'], origin[0], origin[1]) # reset labels for l in labels: cardHandle.addLabel(l) else: # card was created here or manually moved here; # mark active (green) and add a generic project origin entry cardHandle.addLabel('green') originDB[str(card['id'])]= (keys.listIds['general'], 'top') changesMade= True # for each card in Active / Finished that has been archived activeFinishedCards= List(client, keys.listIds['finished']) activeFinishedCardsInfo= activeFinishedCards.fetchJson(activeFinishedCards.base_uri+'/cards', query_params={'filter':'closed'}) closedBoard= Board(client, keys.boardIds['closed']) for card in activeFinishedCardsInfo: cardHandle= Card(client, card['id']) changesMade= True # find origin destination try: originListId, pos= originDB[str(card['id'])] destListName= List(client, originListId).getListInformation()['name'] destListId= None # get id in closed board for list with that name, or else make one for l in closedBoard.getListsJson(closedBoard.base_uri): if l['name'] == destListName: #print '[%s] [%s] %s' %(l['name'], destListName, l['name'] == destListName) destListId= (l['id'], 'top') if not destListId: newList= closedBoard.addList({'name': destListName, 'pos': 'bottom'}) #print 'CREATED:', newList.name, newList.id destListId= (newList.id, 'top') except (ResourceUnavailable, KeyError): # fallback dest destListId= (keys.listIds['closed general'], 'top') destListName= 'General' # remove project list name from its description desc= markProjectInDesc(card['desc'], None) cardHandle.setDesc(desc) #print card['name'], 'to:', destListName, destListId[0] try: # move card to destination list on closed board and un-archive cardHandle.moveTo(keys.boardIds['closed'], destListId[0], destListId[1]) cardHandle.setClosed('false') except ResourceUnavailable: # sometimes new lists aren't ready quite yet. Let's try next time pass originDB.sync() return changesMade
def __init__( self ): self.client = Client( api_key, user_auth_token ) self.board = Board( self.client, board_id )
def card_names_and_ids(self): """Returns [(name, id), ...] pairs of cards from current board""" b = Board(self.client, self.board_id) cards = b.getCards() card_names_and_ids = [(unidecode(c.name.decode('utf8')), c.id) for c in cards] return card_names_and_ids
import re import ast import sys from pprint import pprint from trolly.client import Client from trolly.board import Board from trolly.list import List import keys if __name__ == '__main__': client= Client(keys.api_key, keys.user_auth_token) board= Board(client, sys.argv[1]) for l in board.getLists(): print l.name, l.id
def card_names_and_ids(self): """Returns [(name, id), ...] pairs of cards from current board""" b = Board(self.client, self.board_id) cards = b.getCards() card_names_and_ids = [(unidecode(c.name), c.id) for c in cards] return card_names_and_ids
def board_id(self): board_id = self.ask_for_board_id() Board(self.client, board_id).getBoardInformation() # raises errors if bad board id return board_id
def __init__(self, trelloClient, boardId): Board.__init__(self, trelloClient, boardId)
class TrelloTests(unittest.TestCase): def setUp(self): self.client = Client(api_key, user_auth_token) self.org = Organisation(self.client, organisation) self.board = Board(self.client, board_id) self.list = List(self.client, list_id) self.card = Card(self.client, card_id) self.checklist = Checklist(self.client, checklist_id) self.member = Member(self.client, member_id) def tearDown(self): pass def test_org_01_getOrgInfo(self): result = self.org.get_organisation_information() self.assertIsNotNone(result, 'JSON was empty') def test_org_02_getBoards(self): for board in self.org.get_boards(): self.assertIsNotNone(board.id, msg="ID has not been provided") self.assertIsNotNone(board.name, msg="Name has not been provided") def test_org_03_getMembers(self): for member in self.org.get_members(): self.assertIsNotNone(member.id, msg="ID has not been provided") self.assertIsNotNone(member.name, msg="Name has not been provided") def test_org_04_updateOrganisation(self): description = str(uuid.uuid1()) new_organisation = self.org.update_organisation({'desc': description}) new_description = new_organisation.get_organisation_information()['desc'] self.assertEqual(description, new_description, msg="Descriptions don't match. Update Organisation didn't work!") def test_boa_01_getBoardInformation(self): result = self.board.get_board_information() self.assertIsNotNone(result, 'JSON was empty') def test_boa_02_getLists(self): for lis in self.board.get_lists(): self.assertIsNotNone(lis.id, msg="ID has not been provided") self.assertIsNotNone(lis.name, msg="Name has not been provided") def test_boa_03_getCards(self): for card in self.board.get_cards(): self.assertIsNotNone(card.id, msg="ID has not been provided") self.assertIsNotNone(card.name, msg="Name has not been provided") def test_boa_04_getCard(self): card = self.board.get_card(card_id) self.assertIsNotNone(card.id, msg="ID has not been provided") self.assertIsNotNone(card.name, msg="Name has not been provided") def test_boa_05_getMembers(self): for member in self.board.get_members(): self.assertIsNotNone(member.id, msg="ID has not been provided") self.assertIsNotNone(member.name, msg="Name has not been provided") def test_boa_06_getOrganisation(self): organisation = self.board.get_organisation() self.assertIsNotNone(organisation.id, msg="ID has not been provided") self.assertIsNotNone(organisation.name, msg="Name has not been provided") def test_boa_07_updateBoard(self): description = str(uuid.uuid1()) new_board = self.board.update_board({'desc': description}) new_description = new_board.get_board_information()['desc'] self.assertEqual(description, new_description, msg="Descriptions don't match. Update Board didn't work!") def test_boa_08_addList(self): name = str(uuid.uuid1()) new_list = self.board.add_list({'name': name}) new_list_name = new_list.name self.assertEqual(name, new_list_name, msg="Names don't match. Add list didn't work!") def test_lis_01_getListInformation(self): result = self.list.get_list_information() self.assertIsNotNone(result, 'JSON was empty') def test_lis_02_getBoard(self): board = self.list.get_board() self.assertIsNotNone(board.id, msg="ID has not been provided") self.assertIsNotNone(board.name, msg="Name has not been provided") def test_lis_03_getCards(self): for card in self.list.get_cards(): self.assertIsNotNone(card.id, msg="ID has not been provided") self.assertIsNotNone(card.name, msg="Name has not been provided") def test_lis_04_updateList(self): name = str(uuid.uuid1()) new_list = self.list.update_list({'name': name}) new_list_name = new_list.name self.assertEqual(name, new_list_name, msg="Names don't match. Update list didn't work!") def test_lis_05_addCard(self): name = str(uuid.uuid1()) new_card = self.list.add_card({'name': name}) new_card_name = new_card.name self.assertEqual(name, new_card_name, msg="Names don't match. Add card didn't work!") def test_car_01_getCardInformation(self): result = self.card.get_card_information() self.assertIsNotNone(result, 'JSON was empty') def test_car_02_getBoard(self): board = self.card.get_board() self.assertIsNotNone(board.id, msg="ID has not been provided") self.assertIsNotNone(board.name, msg="Name has not been provided") def test_car_03_getList(self): lis = self.card.get_list() self.assertIsNotNone(lis.id, msg="ID has not been provided") self.assertIsNotNone(lis.name, msg="Name has not been provided") def test_car_04_getChecklists(self): for checklist in self.card.get_checklists(): self.assertIsNotNone(checklist.id, msg="ID has not been provided") self.assertIsNotNone(checklist.name, msg="Name has not been provided") def test_car_05_getMembers(self): for member in self.card.get_members(): self.assertIsNotNone(member.id, msg="ID has not been provided") self.assertIsNotNone(member.name, msg="Name has not been provided") def test_car_06_updateCard(self): description = str(uuid.uuid1()) new_card = self.card.update_card({'desc': description}) new_description = new_card.getCardInformation()['desc'] self.assertEqual(description, new_description, msg="Descriptions don't match. Update Card didn't work!") def test_car_07_addComments(self): comment = str(uuid.uuid1()) result = self.card.add_comments(comment) new_comment = result['data']['text'] self.assertEqual(comment, new_comment, msg="Comments don't match. Add comment didn't work!") def test_car_08_addAttachment(self): f = open('test/test.txt', 'r').read() result = self.card.add_attachment('text.txt', f) self.assertIsNotNone(result, "Got nothing back, doesn't look like it worked!") def test_car_09_addChecklists(self): name = str(uuid.uuid1()) new_checklist = self.card.add_checklists({'name': name}) new_checklist_name = new_checklist.name self.assertEqual(name, new_checklist_name, "Names don't match. Add Checklist failed!") def test_car_10_addLabels(self): try: label_colour = 'green' result = self.card.add_labels({'value': label_colour}) found_label = False for label in result: if label['color'] == label_colour: found_label = True self.assertTrue(found_label, "Label wasn't added!") except ResourceUnavailable: # Label already added pass def test_car_11_addMember(self): try: result = self.card.add_member(member_id) found_member = False for member in result: if member.id == member_id: found_member = True self.assertTrue(found_member, "Member wasn't added to card!") except ResourceUnavailable: # Member is already on the card pass def test_car_12_removeMember(self): try: result = self.card.remove_member(member_id) self.assertIsNotNone(result, "JSON failure! Nothing was returned") for member in result: self.assertNotEqual(member['id'], member_id, "Member was not removed!") except ResourceUnavailable: # Member isn't attached to card pass def test_che_01_getChecklistInformation(self): result = self.checklist.get_checklist_information() self.assertIsNotNone(result, 'JSON was empty') def test_che_02_getItems(self): result = self.checklist.get_items() self.assertIsNotNone(result, 'JSON was empty') def test_che_03_updateChecklist(self): name = str(uuid.uuid1()) new_checklist = self.checklist.update_checklist(name) new_name = new_checklist.name self.assertEqual(name, new_name, msg="Names don't match. Update didn't work!") def test_che_04_addItem(self): name = str(uuid.uuid1()) result = self.checklist.add_item({'name': name}) new_item_name = result['name'] self.assertEqual(name, new_item_name, "Names don't match! Add item failed") def test_che_05_removeItem(self): items = self.checklist.get_items() if len(items) > 0: item_id = items[0]['id'] result = self.checklist.remove_item(item_id) self.assertIsNotNone(result, "JSON was empty!") def test_mem_01_getMemberInformation(self): result = self.member.get_member_information() self.assertIsNotNone(result, 'JSON was empty') def test_mem_02_getBoards(self): for board in self.member.get_boards(): self.assertIsNotNone(board.id, msg="ID has not been provided") self.assertIsNotNone(board.name, msg="Name has not been provided") def test_mem_03_getCards(self): for cards in self.member.get_cards(): self.assertIsNotNone(cards.id, msg="ID has not been provided") self.assertIsNotNone(cards.name, msg="Name has not been provided")
def __init__(self): #self.conn = TrelloConnection('3dd167f33e6de7d4f13fcd138346210c', 'ba57d7a637f46d664b8e30a0d8f50642c55c117dadf23cf7c699c51be5e36cbd') self.client = Client(api_key=os.getenv('TRELLO_APP_KEY'), user_auth_token=os.getenv('TRELLO_OAUTH_TOKEN')) self.board = Board(self.client, os.getenv('TRELLO_BOARD'))
class TrelloBoard(QtGui.QMainWindow): pointingMultiplier = QtCore.pyqtSignal(int) def __init__(self, client, app, boardId, config): QtGui.QMainWindow.__init__(self) self.lists = [] self.app = app self.client = client self.boardId = boardId self.config = config self.trelloBoardStyle = self.config.get('TrelloBoard', 'style') self.board = Board(client, boardId) self.screen = QtGui.QDesktopWidget().screenGeometry() self.setMouseTracking(True) self.updatePointingMultiplier() self.style() self.show() def style(self): self.window = QtGui.QWidget(); hbox = QtGui.QHBoxLayout() self.window.setLayout(hbox) self.setCentralWidget(self.window) hbox.setSpacing(0) lists = self.board.getLists() for rawlist in lists: cards = rawlist.getCards() hbox.addWidget( TrelloList( self.config, self, self.client, rawlist.id, rawlist.name, cards ) ) self.scrollArea = QtGui.QScrollArea() self.scrollArea.setWidgetResizable(True) self.scrollArea.setEnabled(True) self.scrollArea.setWidget(self.window) self.scrollArea.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.scrollArea.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.setCentralWidget(self.scrollArea) self.currentCard = None self.shadowCard = None self.setWindowTitle(self.config.get('main', 'title')) self.setWindowFlags(QtCore.Qt.FramelessWindowHint) self.setStyleSheet(self.trelloBoardStyle) self.logo = QtGui.QLabel(self) self.logo.setPixmap(QtGui.QPixmap(os.getcwd() + self.config.get('resources', 'trellol_logo_small'))) #self.cursorImg = QtGui.QPixmap(os.getcwd() + self.config.get('resources', 'ball_cursor')) self.cursorImg = QtGui.QPixmap(os.getcwd() + self.config.get('resources', 'null_cursor')) self.setCursor(QtGui.QCursor(self.cursorImg, -1, -1)) self.center() def center(self): mainposx = self.config.getint('main', 'pos_x') mainposy = self.config.getint('main', 'pos_y') mainwidth = self.config.getint('main', 'width') mainheight = self.config.getint('main', 'height') self.setGeometry(mainposx, mainposy, mainwidth, mainheight) size = self.geometry() self.move((self.screen.width() - size.width()) / 2, (self.screen.height() - size.height()) / 2) def keyPressEvent(self, event): key = event.key() if key == QtCore.Qt.Key_Escape: self.close() elif key == QtCore.Qt.Key_F: if self.windowState() & QtCore.Qt.WindowFullScreen: self.showNormal() else: self.showFullScreen() self.updatePointingMultiplier() return QtGui.QWidget.keyPressEvent(self, event) def resizeEvent(self, e): logo_h = self.config.getint('TrelloBoard', 'logo_height') logo_w = self.config.getint('TrelloBoard', 'logo_width') logo_x = self.config.getint('TrelloBoard', 'logo_pos_x') logo_y = self.height() - logo_h - self.config.getint('TrelloBoard', 'logo_pos_x') self.logo.setGeometry(logo_x, logo_y, logo_w, logo_h) def mouseMoveEvent(self, event): if (self.currentCard is not None): TrelloCard.mouseMoveEvent(self.currentCard, event) def mousePressEvent(self, event): if (self.currentCard is not None): self.cardDetails = TrelloCardDescription(self, self.currentCard.id) self.cardDetails.exec_() def updatePointingMultiplier(self): diagonal = math.sqrt( (math.pow(self.width(), 2) + math.pow(self.height(), 2))) multiplier = max(min(diagonal / 100, 20), 5) self.pointingMultiplier.emit(multiplier)
def __init__(self): self.client = Client(api_key, user_auth_token) self.board = Board(self.client, board_id)