summaryrefslogtreecommitdiff
path: root/lj_matrix/misc.py
diff options
context:
space:
mode:
authorDavid Luevano <55825613+luevano@users.noreply.github.com>2019-12-18 07:21:35 -0700
committerDavid Luevano <55825613+luevano@users.noreply.github.com>2019-12-18 07:21:35 -0700
commit487bf8840846b5d4d694b38985268c308aadb36e (patch)
treeba3a3a742a503f925a5a7792e1bd16ee518066c9 /lj_matrix/misc.py
parent96a3f2b2950451a478c951e642a4aa188219682b (diff)
Refactor files
Diffstat (limited to 'lj_matrix/misc.py')
-rw-r--r--lj_matrix/misc.py53
1 files changed, 53 insertions, 0 deletions
diff --git a/lj_matrix/misc.py b/lj_matrix/misc.py
new file mode 100644
index 000000000..c50653a5c
--- /dev/null
+++ b/lj_matrix/misc.py
@@ -0,0 +1,53 @@
+"""MIT License
+
+Copyright (c) 2019 David Luevano Alvarado
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+"""
+from colorama import init, Fore, Style
+
+init()
+
+
+def printc(text, color):
+ """
+ Prints texts normaly, but in color. Using colorama.
+ text: string with the text to print.
+ color: color to be used, same as available in colorama.
+ """
+ color_dic = {'BLACK': Fore.BLACK,
+ 'RED': Fore.RED,
+ 'GREEN': Fore.GREEN,
+ 'YELLOW': Fore.YELLOW,
+ 'BLUE': Fore.BLUE,
+ 'MAGENTA': Fore.MAGENTA,
+ 'CYAN': Fore.CYAN,
+ 'WHITE': Fore.WHITE,
+ 'RESET': Fore.RESET}
+
+ color_dic_keys = color_dic.keys()
+ if color not in color_dic_keys:
+ print(Fore.RED
+ + '\'{}\' not found, using default color.'.format(color)
+ + Style.RESET_ALL)
+ actual_color = Fore.RESET
+ else:
+ actual_color = color_dic[color]
+
+ print(actual_color + text + Style.RESET_ALL)