Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Colorclass removal #172

Merged
merged 5 commits into from
Nov 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Interlace/lib/core/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.9.6'
__version__ = '1.9.7'
37 changes: 26 additions & 11 deletions Interlace/lib/core/output.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
from enum import IntEnum
from time import localtime, strftime

from colorclass import Color
from colorclass import disable_all_colors

from Interlace.lib.core.__version__ import __version__


class bcolors:
# credit to: https://stackoverflow.com/questions/287871/how-do-i-print-colored-text-to-the-terminal
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKCYAN = '\033[96m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'


class OutputHelper(object):
def __init__(self, arguments):
if arguments.nocolor:
disable_all_colors()

self._no_color = arguments.nocolor
self.verbose = arguments.verbose
self.silent = arguments.silent
self.seperator = "====================================================="
Expand All @@ -29,11 +37,18 @@ def terminal(self, level, target, command, message=""):
if level == 0 and not self.verbose:
return

formatting = {
0: Color('{autoblue}[VERBOSE]{/autoblue}'),
1: Color('{autogreen}[THREAD]{/autogreen}'),
3: Color('{autobgyellow}{autored}[ERROR]{/autored}{/autobgyellow}')
}
if not self._no_color:
formatting = {
0: f'{bcolors.OKBLUE}[VERBOSE]{bcolors.ENDC}',
1: f'{bcolors.OKGREEN}[THREAD]{bcolors.ENDC}',
3: f'{bcolors.FAIL}[ERROR]{bcolors.ENDC}'
}
else:
formatting = {
0: '[VERBOSE]',
1: '[THREAD]',
3: '[ERROR]'
}

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

Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
colorclass==2.2.2
netaddr==0.7.20
tqdm==4.62.3