Make colorama optional

This commit is contained in:
Fierelier 2021-12-29 21:01:20 +01:00
parent f7dcc8535c
commit 0cb75fd41f

47
run.py
View File

@ -23,8 +23,51 @@ import api.opusnt as opusnt
import json
import subprocess
import winreg
import colorama
colorama.init()
class coloramaFallback:
class Fore:
BLACK = ""
RED = ""
GREEN = ""
YELLOW = ""
BLUE = ""
MAGENTA = ""
CYAN = ""
WHITE = ""
RESET = ""
class Back:
BLACK = ""
RED = ""
GREEN = ""
YELLOW = ""
BLUE = ""
MAGENTA = ""
CYAN = ""
WHITE = ""
RESET = ""
class Style:
DIM = ""
NORMAL = ""
BRIGHT = ""
RESET_ALL = ""
def coloramaInit():
global colorama
coloramaSuccess = False
if not "-nocolor" in sys.argv:
try:
import colorama
colorama.init()
coloramaSuccess = True
except Exception as e:
print("Could not import/init colorama: " +str(e),file=sys.stderr)
print("Colors deactivated.\n",file=sys.stderr)
if not coloramaSuccess:
colorama = coloramaFallback
coloramaInit()
def runCode(str, lcs = False, description = "loose-code"):
if lcs == False: lcs = {}