class LeankitKanban(object): def __init__(self, account, email, password): self.connector = LeankitConnector(account, email, password) self._boards = [] self._boards_by_id = {} self._boards_by_title = {} def get_boards(self, include_archived=False): """List all the boards user has access to. :param include_archived: if True, include archived boards as well. """ boards_data = self.connector.get('/Boards').ReplyData boards = [] for board_dict in boards_data[0]: board = LeankitBoard(board_dict, self.connector) if board.is_archived and not include_archived: continue boards.append(board) return boards def _refresh_boards_cache(self): self._boards = self.get_boards(True) self._boards_by_id = {} self._boards_by_title = {} for board in self._boards: self._boards_by_id[board.id] = board self._boards_by_title[board.title] = board def _find_board_in_cache(self, board_id=None, title=None): assert title is not None or board_id is not None, ( "Either a board title or board id are required.") if board_id is not None and board_id in self._boards_by_id: return self._boards_by_id[board_id] elif title in self._boards_by_title: return self._boards_by_title[title] else: return None def _find_board(self, board_id=None, title=None): board = self._find_board_in_cache(board_id, title) if board is None: # Not found, try once more after refreshing the cache. self._refresh_boards_cache() board = self._find_board_in_cache(board_id, title) return board def get_board(self, board_id=None, title=None): board = self._find_board(board_id, title) if board is not None: board.fetch_details() return board
def __init__(self, account, email, password): self.connector = LeankitConnector(account, email, password) self._boards = [] self._boards_by_id = {} self._boards_by_title = {}