def build_report(config, trello): reporter = Reporter() for list_spec in config["lists"]: trello_list = trello.list(list_spec["listId"]) old_cards = [ card for card in trello_list["cards"] if older_than(card["dateLastActivity"], list_spec["timeDelta"]) ] if not old_cards: continue reporter.add_section(trello_list["name"], [card["name"] for card in old_cards]) if not reporter.sections: return None return reporter.format(config["heading"])