Advertisement
Guest User

write.py

a guest
Jun 17th, 2021
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1. from colorama import init
  2. from sys import stdout
  3.  
  4. init()
  5.  
  6. def write(type: str, message: str) -> None:
  7.     if stdout.writelines is False:
  8.         return
  9.    
  10.     if type.lower() == 'info':
  11.         stdout.write(
  12.             '({GREEN}Info{RESET}): {MESSAGE}'.format(
  13.                 GREEN='\x1b[32m',
  14.                 RESET='\x1b[0m',
  15.                 MESSAGE=message
  16.             )
  17.         )
  18.    
  19.     elif type.lower() == 'error':
  20.         stdout.write(
  21.             '({RED}Error{RESET}): {MESSAGE}'.format(
  22.                 RED='\x1b[31m',
  23.                 RESET='\x1b[0m',
  24.                 MESSAGE=message
  25.             )
  26.         )
  27.    
  28.     else:
  29.         return
  30.  
  31. def writeline(type: str, message: str) -> None:
  32.     write(type, '{}\n'.format(message))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement