-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcoloredMessages.py
executable file
·79 lines (52 loc) · 1.75 KB
/
coloredMessages.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
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
77
78
79
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
.. codeauthor:: Wilfried Mercier - IRAP/LAM <[email protected]>
General functions to format io output using ANSII sequences using colorama.
"""
import colorama as col
def errorMessage(text):
'''
.. codeauthor:: Wilfried Mercier - IRAP/LAM <[email protected]>
Colorise text in red and emphasise it for error messages.
:param str text: text
:returns: colorised text
:rtype: str
'''
return col.Fore.RED + col.Style.BRIGHT + text + col.Style.RESET_ALL
def okMessage(text):
'''
.. codeauthor:: Wilfried Mercier - IRAP/LAM <[email protected]>
Dim green text for validation messages.
:param str text: text
:returns: colorised text
:rtype: str
'''
return col.Fore.GREEN + col.Style.DIM + text + col.Style.RESET_ALL
def brightMessage(text):
'''
.. codeauthor:: Wilfried Mercier - IRAP/LAM <[email protected]>
Emphasize a text by brightening it.
:param str text: text
:returns: brightened text
:rtype: str
'''
return col.Style.BRIGHT + text + col.Style.RESET_ALL
def dimMessage(text):
'''
.. codeauthor:: Wilfried Mercier - IRAP/LAM <[email protected]>
Dim a text.
:param str text: text
:returns: dimmed text
:rtype: str
'''
return col.Style.DIM + text + col.Style.RESET_ALL
def warningMessage(text):
'''
.. codeauthor:: Wilfried Mercier - IRAP/LAM <[email protected]>
Same as error message but using yellow instead of red.
:param str text: text
:returns: colorised text
:rtype: str
'''
return col.Style.BRIGHT + col.Fore.YELLOW + text + col.Style.RESET_ALL