The py-trello api allows for cloning cards. The method add_card() can be called on a list object. You can input a variable called “source” which is the card ID of the card you want to clone. The cloning will duplicate comments, checklists, and attachments.
def create_cards_on_new_lists(new_board_lists, master_lists, board_labels): new_cards =  for list_name, cards in master_lists.items(): for card in cards: new_card = new_board_lists[list_name].add_card(card.name, source=card.id) new_card.add_label(board_labels[list_name]) return new_cards
This is the test case for detecting checklists. This one is interesting for me because it is also an example of list comprehension. I forgot how to do it, so had to do it again.
[x[“name”] for x in new_checklist.items]
This goes through a list of checklist objects, and goes through and gets the name and puts it into a list.
def test_add_checklists_to_cards(self): new_boards = trello_auto.do_everything(self.masterboard.id, API_KEY, API_TOKEN) new_checklist = new_boards.open_cards().fetch_checklists() self.assertEqual("Checklist", new_checklist.name) self.assertEqual(["item1", "item2"], [x["name"] for x in new_checklist.items])
This test goes and just takes the first checklist on the first card on the first board in the new boards. Then it takes the name and see if the name matches the set name (“Checklist”) and then checks the items through the list comprehension.