Skip to content

Commit

Permalink
update colors using colorama
Browse files Browse the repository at this point in the history
  • Loading branch information
urmi-21 committed Sep 8, 2020
1 parent 95ab489 commit 36b970d
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 17 deletions.
65 changes: 49 additions & 16 deletions pyrpipe/pyrpipe_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

import os
import datetime as dt
import sys
from colorama import Fore,Back,Style



Expand Down Expand Up @@ -39,7 +41,8 @@ def print_boldred(text):
Returns: None
"""
print (Colors.FAIL + Colors.BOLD+ text + Colors.ENDC)
#print (Colors.FAIL + Colors.BOLD+ text + Colors.ENDC)
print_error(text)

def print_green(text):
"""Print in green font
Expand All @@ -52,7 +55,8 @@ def print_green(text):
Returns: None
"""
print (Colors.OKGREEN + text + Colors.ENDC)
#print (Colors.OKGREEN + text + Colors.ENDC)
print_success(text)

def print_blue(text):
"""Print in blue font
Expand All @@ -65,19 +69,10 @@ def print_blue(text):
Returns: None
"""
print (Colors.OKBLUE + text + Colors.ENDC)
#print (Colors.OKBLUE + text + Colors.ENDC)
print_message(text)


def print_magenta(text):
"""Print in magenta font
Parameters
----------
text(str): text to print
Returns: None
"""
print (Colors.LightMagenta + text + Colors.ENDC)

def print_info(text):
"""Print an info message
Expand All @@ -90,7 +85,8 @@ def print_info(text):
Returns: None
"""
print_magenta(text)
#print_magenta(text)
print_information(text)

def print_yellow(text):
"""Print in yellow font
Expand All @@ -103,7 +99,44 @@ def print_yellow(text):
Returns: None
"""
print (Colors.LightYellow + text + Colors.ENDC)
#print (Colors.LightYellow + text + Colors.ENDC)
print_notification(text)


def pyrpipe_print(color,*args,stderr=False,**kwargs):
if stderr:
print(color,file=sys.stderr,end="",**kwargs)
print(*args,file=sys.stderr,end="",**kwargs)
print(Style.RESET_ALL,file=sys.stderr,**kwargs)
else:
print(color,file=sys.stdout,end="",**kwargs)
print(*args,file=sys.stdout,end="",**kwargs)
print(Style.RESET_ALL,file=sys.stdout,**kwargs)

def print_notification(*args):
"""Print message to stderr
"""
pyrpipe_print(Fore.LIGHTYELLOW_EX,*args,stderr=True)

def print_message(*args):
"""Print message to stderr
"""
pyrpipe_print(Fore.LIGHTCYAN_EX,*args,stderr=True)

def print_information(*args):
"""Print message to stderr
"""
pyrpipe_print(Fore.LIGHTMAGENTA_EX,*args,stderr=True)

def print_error(*args):
"""Print message to stderr
"""
pyrpipe_print(Fore.LIGHTRED_EX,*args,stderr=True)

def print_success(*args):
"""Print message to stderr
"""
pyrpipe_print(Fore.LIGHTGREEN_EX,*args,stderr=True)

######End color functions###################

Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ weasyprint
importlib_resources
multiqc
seaborn
pyyaml
pyyaml
colorama

0 comments on commit 36b970d

Please sign in to comment.