~mapperr/trl

ref: f9ade6c361774e3f717a873119675bc10a1d577f trl/trullo/printer.py -rw-r--r-- 1.9 KiB
f9ade6c3 — mapperr Fix readme 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from typing import List

import attr

from trullo.shortener import Shortener
from trullo.trl_board import TrlBoard
from trullo.trl_card import TrlCard


@attr.s(auto_attribs=True)
class Printer:
    @staticmethod
    def print_boards(boards: List[TrlBoard]):
        symbol_count = Shortener.get_min_symbols_to_uniq([board.shortcut.lower() for board in boards])
        for board in boards:
            print(f"[{board.shortcut[0:symbol_count].lower()}] {board.raw_data['name']}")

    @staticmethod
    def print_board(board: TrlBoard, list_shortcut: str = None):
        symbol_count_cards = Shortener.get_min_symbols_to_uniq([card.shortcut for card in board.cards])
        symbol_count_lists = Shortener.get_min_symbols_to_uniq([list_.id for list_ in board.lists], True)
        print(f"Board: {board.raw_data['name']}\n")
        if board.lists is not None:
            for list_ in board.lists:
                if list_shortcut is not None and not list_.id.lower().endswith(list_shortcut):
                    continue
                print(
                    f"[{list_.id[len(list_.id) - symbol_count_lists:len(list_.id)].lower()}] {list_.raw_data['name']}")
                for card in board.cards:
                    if card.raw_data['idList'] == list_.id:
                        print(f"\t[{card.shortcut[0:symbol_count_cards].lower()}] {card.raw_data['name']}")

    @staticmethod
    def print_card(card: TrlCard):
        # pp = pprint.PrettyPrinter(indent=4).pprint(card.raw_data)
        d = card.raw_data

        formatted_desc = '\t' + str(d['desc']).replace('\n', '\n\t')

        print()
        print(f'{d["name"]}')
        print('-------------------------------------')
        for l in d['labels']:
            print(f'({l["name"]})\t', end='')
        print()
        print()
        print(formatted_desc)
        print()
        print()
        print(f'{d["shortUrl"]}')
        print()