Last active
March 4, 2019 23:39
-
-
Save roman-ku/749125c854e30351112ccad8f2175687 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
from pprint import pprint as pp | |
from trello import TrelloClient | |
client = TrelloClient( | |
api_key='your-key', | |
api_secret='your-secret', | |
token='your-oauth-token-key', | |
token_secret='your-oauth-token-secret' | |
) | |
def next_monday(): | |
# http://stackoverflow.com/a/6558571 | |
day = datetime.date.today() | |
days_ahead = 0 - day.weekday() | |
if days_ahead <= 0: # Target day already happened this week | |
days_ahead += 7 | |
return day + datetime.timedelta(days_ahead) | |
for board in client.list_boards(): | |
if board.name == "School Stuff": | |
lists_to_del = [] | |
# find all empty lists in a board | |
print('Finding all empty lists...', end='') | |
for board_list in board.open_lists(): | |
if len(board_list.list_cards()) == 0: | |
lists_to_del.append(board_list) | |
print('found {}.'.format(len(lists_to_del))) | |
# close all empty lists: | |
if (len(lists_to_del) > 0): | |
print('Closing {} empty board(s)...'.format(len(lists_to_del)), end='') | |
for empty_list in lists_to_del: | |
empty_list.close() | |
print('done.') | |
# creating new boards for the week | |
print('Creating new boards for the week...', end='') | |
week_start = next_monday() | |
for day in range(7): | |
week_day = week_start + datetime.timedelta(days=day) | |
board.add_list(week_day.strftime('%A (%m/%d/%Y)'), 'bottom') | |
print('done.') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment