cprint.py 918 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/usr/bin/python3
  2. import sys
  3. icolor = 1
  4. def cprint(*text,color="blue",space=" ",end="\n"):
  5. #return 0 #disable print dbg
  6. if not color:
  7. print(text)
  8. return 0
  9. if color == "green":
  10. txt = '\033[92m'
  11. elif color == "red":
  12. txt = '\033[0;31m\033[1m'
  13. elif color == "yellow":
  14. txt = '\033[93m\033[1m'
  15. elif color == "cyan":
  16. txt = '\033[96m'
  17. else:
  18. txt = '\033[94m'
  19. for t in text:
  20. txt += str(t ) +" "
  21. #HEADER = '\033[95m'
  22. #OKBLUE = '\033[94m'
  23. #OKCYAN = '\033[96m'
  24. #OKGREEN = '\033[92m'
  25. #WARNING = '\033[93m'
  26. #FAIL = '\033[91m'
  27. #ENDC = '\033[0m'
  28. #BOLD = '\033[1m'
  29. #UNDERLINE = '\033[4m'
  30. txt += '\033[0m'
  31. print(txt,end=end)
  32. #return txt
  33. try:
  34. sys.stdout.flush() # to grep output
  35. except BrokenPipeError as e:
  36. print("BROKEN PIPE ERROR CPRINT = EXIT")
  37. #exit()