-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
53 lines (45 loc) · 1.31 KB
/
Copy pathconfig.py
File metadata and controls
53 lines (45 loc) · 1.31 KB
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
# ============================================================================
# config.py
# ============================================================================
"""
Configuration and constants for WPFileScan
"""
import re
# Version
VERSION = "1.0.0"
class Colors:
"""Centralized color theme for the entire application"""
HEADER = '\033[95m'
BLUE = '\033[94m'
CYAN = '\033[96m'
GREEN = '\033[92m'
YELLOW = '\033[93m'
RED = '\033[91m'
PURPLE = '\033[95m'
RESET = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
SUCCESS = GREEN
ERROR = RED
WARNING = YELLOW
INFO = CYAN
HIGHLIGHT = BLUE
HEADER_COLOR = PURPLE
RESULT = GREEN
@classmethod
def colorize(cls, text: str, color: str) -> str:
return f"{color}{text}{cls.RESET}"
@classmethod
def colorize_parts(cls, *parts) -> str:
result = []
for text, color in parts:
if color:
result.append(cls.colorize(text, color))
else:
result.append(text)
return ''.join(result)
@classmethod
def strip_colors(cls, text: str) -> str:
"""Remove ANSI color codes from text"""
ansi_escape = re.compile(r'\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])')
return ansi_escape.sub('', text)