From 82d8f4b933a7929b707ce65e50d02ac71df0247f Mon Sep 17 00:00:00 2001 From: Esko Kokkonen Date: Sat, 24 Sep 2011 17:32:24 +0300 Subject: [PATCH] give_time(): Add nocolor option Calling the noclor=True causes the function to return the time string without the colors. --- emerge-timer.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/emerge-timer.py b/emerge-timer.py index 137ce43..9ab7cab 100755 --- a/emerge-timer.py +++ b/emerge-timer.py @@ -154,8 +154,14 @@ class package: -def give_time(time): +def give_time(time, nocolor=False): """Converts time in seconds to human readable form""" + global green_start, color_stop + + if nocolor == True: + green_start = "" + color_stop = "" + days = time/(3600*24) hours = (days - int(days))*24 minutes = (hours - int(hours))*60 @@ -198,6 +204,9 @@ def give_time(time): pseconds = (green_start + str(seconds) + color_stop + " seconds ") + green_start = "\033[32m" + color_stop = "\033[m" + return (pdays + phours + pminutes + pseconds) -- 2.45.0