Skip to content

Commit 7823e42

Browse files
authored
Merge pull request #172 from codingo/colorclass-removal
Colorclass removal
2 parents 97ee21e + 78b8db6 commit 7823e42

File tree

3 files changed

+27
-13
lines changed

3 files changed

+27
-13
lines changed

Interlace/lib/core/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '1.9.6'
1+
__version__ = '1.9.7'

Interlace/lib/core/output.py

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
11
from enum import IntEnum
22
from time import localtime, strftime
33

4-
from colorclass import Color
5-
from colorclass import disable_all_colors
6-
74
from Interlace.lib.core.__version__ import __version__
85

96

7+
class bcolors:
8+
# credit to: https://stackoverflow.com/questions/287871/how-do-i-print-colored-text-to-the-terminal
9+
HEADER = '\033[95m'
10+
OKBLUE = '\033[94m'
11+
OKCYAN = '\033[96m'
12+
OKGREEN = '\033[92m'
13+
WARNING = '\033[93m'
14+
FAIL = '\033[91m'
15+
ENDC = '\033[0m'
16+
BOLD = '\033[1m'
17+
UNDERLINE = '\033[4m'
18+
19+
1020
class OutputHelper(object):
1121
def __init__(self, arguments):
12-
if arguments.nocolor:
13-
disable_all_colors()
14-
22+
self._no_color = arguments.nocolor
1523
self.verbose = arguments.verbose
1624
self.silent = arguments.silent
1725
self.seperator = "====================================================="
@@ -29,11 +37,18 @@ def terminal(self, level, target, command, message=""):
2937
if level == 0 and not self.verbose:
3038
return
3139

32-
formatting = {
33-
0: Color('{autoblue}[VERBOSE]{/autoblue}'),
34-
1: Color('{autogreen}[THREAD]{/autogreen}'),
35-
3: Color('{autobgyellow}{autored}[ERROR]{/autored}{/autobgyellow}')
36-
}
40+
if not self._no_color:
41+
formatting = {
42+
0: f'{bcolors.OKBLUE}[VERBOSE]{bcolors.ENDC}',
43+
1: f'{bcolors.OKGREEN}[THREAD]{bcolors.ENDC}',
44+
3: f'{bcolors.FAIL}[ERROR]{bcolors.ENDC}'
45+
}
46+
else:
47+
formatting = {
48+
0: '[VERBOSE]',
49+
1: '[THREAD]',
50+
3: '[ERROR]'
51+
}
3752

3853
leader = formatting.get(level, '[#]')
3954

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
colorclass==2.2.2
21
netaddr==0.7.20
32
tqdm==4.62.3

0 commit comments

Comments
 (0)