SHARE
TWEET

Untitled

a guest May 21st, 2019 113 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # colors
  2. # Author: Zane Gittins
  3.  
  4. import sys
  5.  
  6. BLACK       =   '\033[30m'
  7. RED         =   '\033[31m'
  8. GREEN       =   '\033[32m'
  9. ORANGE      =   '\033[33m'
  10. BLUE        =   '\033[34m'
  11. PURPLE      =   '\033[35m'
  12. CYAN        =   '\033[36m'
  13. LIGHTGRAY   =   '\033[37m'
  14. DARKGRAY    =   '\033[90m'
  15. LIGHTRED    =   '\033[91m'
  16. LIGHTGREEN  =   '\033[92m'
  17. YELLOW      =   '\033[93m'
  18. LIGHTBLUE   =   '\033[94m'
  19. PINK        =   '\033[95m'
  20. LIGHTCYAN   =   '\033[96m'
  21. ENDC        =   '\033[0m'
  22.  
  23. def pick_color(color):
  24.     color = str(color).upper()
  25.     color_code = ""
  26.  
  27.     if color == "BLACK":
  28.         color_code = BLACK
  29.  
  30.     elif color == "RED":
  31.         color_code = RED
  32.  
  33.     elif color == "GREEN":
  34.         color_code = GREEN
  35.  
  36.     elif color == "ORANGE":
  37.         color_code = ORANGE
  38.  
  39.     elif color == "BLUE":
  40.         color_code = BLUE
  41.  
  42.     elif color == "PURPLE":
  43.         color_code = PURPLE
  44.  
  45.     elif color == "CYAN":
  46.         color_code = CYAN
  47.  
  48.     elif color == "LIGHTGRAY":
  49.         color_code = LIGHTGRAY
  50.  
  51.     elif color == "DARKGRAY":
  52.         color_code = DARKGRAY
  53.  
  54.     elif color == "LIGHTRED":
  55.         color_code = LIGHTRED
  56.  
  57.     elif color == "LIGHTGREEN":
  58.         color_code = LIGHTGREEN
  59.  
  60.     elif color == "YELLOW":
  61.         color_code = YELLOW
  62.  
  63.     elif color == "LIGHTBLUE":
  64.         color_code = LIGHTBLUE
  65.  
  66.     elif color == "PINK":
  67.         color_code = PINK
  68.  
  69.     elif color == "LIGHTCYAN":
  70.         color_code = LIGHTCYAN
  71.  
  72.     return color_code
  73.  
  74. def ctext(color,text):
  75.     color_code = pick_color(color)
  76.     if color_code != "":
  77.         cret = (color_code + str(text) + ENDC)
  78.         return cret
  79.     else:
  80.         return text
  81.  
  82. def cprint(color, text):
  83.     color_code = pick_color(color)
  84.     if color_code != "":
  85.         print(color_code + str(text) + ENDC)
  86.     else:
  87.         print(text)
  88.  
  89. def cwrite(color, text):
  90.     color_code = pick_color(color)
  91.     if color_code != "":
  92.         sys.stdout.write(color_code + str(text) + ENDC)
  93.     else:
  94.         sys.stdout.write(text)
  95.     sys.stdout.flush()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top