]> git.itanic.dy.fi Git - emerge-timer/commitdiff
Don't overwrite global no color flag
authorEsko Kokkonen <esko.kokkonen@gmail.com>
Sat, 24 Sep 2011 14:45:20 +0000 (17:45 +0300)
committerEsko Kokkonen <esko.kokkonen@gmail.com>
Sat, 24 Sep 2011 14:45:20 +0000 (17:45 +0300)
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.

emerge-timer.py

index 7ac3f37083eab7eeba3215e1e5551dc3c3f74fa0..d3896290829339552bb214203a61fe09b3dc45b4 100755 (executable)
@@ -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)