示例#1
0
文件: card.py 项目: trstringer/jersey
def arg_modify(cli_args):
    """Modify an existing card"""

    board = backlog_board()

    card = card_by_id(cli_args.card_id, board)

    if cli_args.remove_due:
        card.remove_due()

    if cli_args.remove_label:
        label_to_remove = [
            _ for _ in card.labels if _.name == cli_args.remove_label
        ]
        if label_to_remove:
            card.remove_label(label_to_remove[0])

    if cli_args.label:
        add_labels = parse_labels(cli_args.label)
        if add_labels:
            card.add_label(add_labels[0])

    if cli_args.due:
        new_due = str(parse_new_due_date(cli_args.due))
        # set_due() expects the due date in a datetime object
        new_due = datetime.strptime(new_due, '%Y-%m-%d %H:%M:%S')
        card.set_due(new_due)
示例#2
0
文件: card.py 项目: trutheddie/jersey
def arg_move(cli_args):
    """Move a card to a new list"""

    board = backlog_board()

    list_name = cli_args.list_name
    try:
        destination_list = [
            _ for _ in board.list_lists()
            if list_name_partially_matches(_.name, list_name)
        ]
        if len(destination_list) > 1:
            print(
                f'{colorama.Fore.RED}More than one list matching string {list_name}'
            )
            return
        destination_list = destination_list[0]
    except IndexError:
        print(f'{colorama.Fore.RED}Destination list not found')
        return

    card = card_by_id(cli_args.card_id, board)
    if not card:
        print(f'{colorama.Fore.RED}Card not found')
        return

    card.change_list(destination_list.id)
示例#3
0
def arg_sort(cli_args):
    """Sort all cards in board"""
    board = backlog_board()

    for trello_list in board.list_lists():
        if trello_list.name != 'done':
            sort_list(trello_list)
示例#4
0
文件: card.py 项目: trutheddie/jersey
def arg_comment(cli_args):
    """Add a comment to a card"""

    board = backlog_board()

    card = card_by_id(cli_args.card_id, board)

    card.comment(cli_args.comment)
示例#5
0
def arg_list_labels(cli_args):
    """List the current labels on the board"""

    board = backlog_board()

    for label in board.get_labels():
        # pylint: disable=line-too-long
        print(label_name_with_color(label))
示例#6
0
def display_list(list_name):
    board = backlog_board()

    lists = board.list_lists()
    input_list = [_ for _ in lists if _.name == list_name][0]

    for card in sorted(input_list.list_cards(),
                       key=lambda card: str(card.due_date)
                       if card.due_date else 'zzz'):
        due_output = format_due_date(card)
        comments_count = len(card.get_comments())
        comments_output = f' {colorama.Fore.GREEN}({comments_count})' if comments_count > 0 else ''
        label_output = ' '.join(
            [label_name_with_color(card_label) for card_label in card.labels])
        # pylint: disable=line-too-long
        print(
            f'{colorama.Fore.YELLOW}{card.id[-CARD_ID_POSTFIX_COUNT:]} {due_output} {colorama.Fore.RESET}{card.name}{comments_output} {label_output}'
        )
示例#7
0
def arg_move(cli_args):
    """Move a card to a new list"""

    board = backlog_board()

    try:
        destination_list = [
            _ for _ in board.list_lists() if _.name == cli_args.list_name
        ][0]
    except IndexError:
        print(f'{colorama.Fore.RED}Destination list not found')
        return

    card = card_by_id(cli_args.card_id, board)
    if not card:
        print(f'{colorama.Fore.RED}Card not found')
        return

    card.change_list(destination_list.id)
示例#8
0
文件: card.py 项目: trutheddie/jersey
def arg_add(cli_args):
    """Add a new card to a given list"""

    try:
        destination_list = [
            _ for _ in backlog_board().list_lists()
            if list_name_partially_matches(_.name, cli_args.list_name)
        ][0]
    except IndexError:
        print(f'{colorama.Fore.RED}Error searching for list')
        return

    new_due = str(parse_new_due_date(cli_args.due))

    add_labels = None
    if cli_args.labels:
        add_labels = parse_labels(cli_args.labels)

    destination_list.add_card(name=cli_args.card_name,
                              due=new_due if cli_args.due else "null",
                              labels=add_labels)

    sort_list(destination_list)
示例#9
0
文件: card.py 项目: trutheddie/jersey
def arg_show(cli_args):
    """Show a card summary"""

    board = backlog_board()

    card = card_by_id(cli_args.card_id, board)

    if not card:
        return

    print(
        f'{colorama.Fore.YELLOW}{colorama.Style.BRIGHT}{card.name}{colorama.Fore.RESET}'
    )
    print(
        f'Due: {format_due_date(card)}{colorama.Fore.RESET}{colorama.Style.NORMAL}'
    )

    for comment in sorted(card.get_comments(),
                          key=lambda c: c['date'],
                          reverse=True):
        comment_datetime = str(dateutil.parser.parse(comment['date']))
        print(f'{colorama.Fore.BLUE}{comment_datetime}', end=' ')
        print(f'{colorama.Fore.GREEN}{comment["data"]["text"]}')
        print(colorama.Fore.RESET, end='')
示例#10
0
def parse_labels(labels_raw):
    """Parse label objects from a raw string"""

    board = backlog_board()
    labels = [_.strip() for _ in labels_raw.split(',')]
    return [_ for _ in board.get_labels() if _.name in labels]