-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathui.py
37 lines (26 loc) · 822 Bytes
/
ui.py
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
from termcolor import colored
from prettytable import PrettyTable
def success(text):
"""Returns a green colored text
"""
return(colored(text, 'green', attrs=['blink', 'bold']))
def magenta(text):
"""Returns a magenta colored text
"""
return(colored(text, 'magenta', attrs=['blink', 'bold']))
def error(text):
"""Returns a red colored text
"""
return(colored(text, 'red', attrs=['blink', 'bold']))
def table(data):
"""Generates and returns a table
"""
x = PrettyTable()
name = colored("Name", 'blue')
phone_number = colored("Phone Number", 'blue')
x.field_names = [name, phone_number]
for contact in data:
contact_name = data[contact][0] + " " + data[contact][1]
x.add_row([contact_name, contact])
x.sortby = name
return(x)