-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresults.py
More file actions
76 lines (60 loc) · 2.06 KB
/
results.py
File metadata and controls
76 lines (60 loc) · 2.06 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# !/usr/bin/env python3
from rich import box
from rich.align import Align
from rich.console import Console, Group
from rich.columns import Columns
from rich.panel import Panel
from rich.table import Table
from rich.text import Text
# Make the console object
c = Console()
class Results:
def set_output_type(self) -> str:
output_type: str = c.input(f"""[bright_white]
Enter output format ("p" = Panels or "t" = Table) >>> """)
return output_type.strip().lower()
def print_results(self, results: str) -> str:
output: str = c.print(f"""[bold blue]
RESULTS OF STRING ROTATION
--------------------------\n
[bold yellow2] {results}\n""")
return output
def print_results_table(self, format, results_dict: dict) -> None:
results_table = Table(
box=box.HORIZONTALS,
show_header=True,
header_style="bold #2070b2",
show_lines=True
)
results_table.add_column(
Text("Format", justify="left"),
justify="left",
no_wrap=False
)
results_table.add_column(
Text("Encoded String", justify="left"),
justify="left",
ratio=2,
no_wrap=False
)
results_table.add_row(
f"[bold green3]Input Value ({format})",
f"""[bold green3]'{results_dict["user_input"]}'"""
)
new_dict = {key: value for key, value in results_dict.items() if key not in ["type", "user_input"]}
for key, value in new_dict.items():
results_table.add_row(
f"[bright_white]{key}",
f"[khaki1]{value}",
end_section=True
)
inner_panel = Panel(
Align.center(Group(Align.left(results_table)), vertical="middle"),
box=box.ROUNDED,
expand=False,
style="none",
border_style="none",
title=f"""Convert from {results_dict["type"].upper()} Input""",
safe_box=True
)
c.print(inner_panel)