From: Esko Kokkonen Date: Sat, 24 Sep 2011 14:45:20 +0000 (+0300) Subject: Don't overwrite global no color flag X-Git-Url: http://git.itanic.dy.fi/?p=emerge-timer;a=commitdiff_plain;h=ac7218a6c236ee044fef1a659113e6e5f2c091f9 Don't overwrite global no color flag This takes into accout if we have defined green_start as "" globally and therefore don't need to do that again in the give_time function. --- diff --git a/emerge-timer.py b/emerge-timer.py index 7ac3f37..d389629 100755 --- a/emerge-timer.py +++ b/emerge-timer.py @@ -160,6 +160,9 @@ def give_time(time, nocolor=False): """Converts time in seconds to human readable form""" global green_start, color_stop + if green_start == "": + nocolor = False + if nocolor == True: green_start = "" color_stop = "" @@ -206,8 +209,9 @@ def give_time(time, nocolor=False): pseconds = (green_start + str(seconds) + color_stop + " seconds ") - green_start = "\033[32m" - color_stop = "\033[m" + if nocolor == True: + green_start = "\033[32m" + color_stop = "\033[m" return (pdays + phours + pminutes + pseconds)