]> git.itanic.dy.fi Git - emerge-timer/commitdiff
Make the file writing into its own function
authorEsko Kokkonen <esko.kokkonen@gmail.com>
Wed, 15 Jun 2011 16:28:46 +0000 (19:28 +0300)
committerEsko Kokkonen <esko.kokkonen@gmail.com>
Wed, 15 Jun 2011 16:28:46 +0000 (19:28 +0300)
emerge-timer.py

index bcf6cb26aaff762acd2f1c0bdc1c7e71c2303e6d..fd8da840a05efc0145988614ed7779cd50f6047d 100755 (executable)
@@ -23,6 +23,16 @@ times = []
 green_start = "\033[1;32m"
 color_stop = "\033[1;m"
 
+def write_times(emerge_times_list):
+    with open('times', 'w') as g:
+
+        for i in times:
+            line = str(i[0]) + " " + str(i[1]) + "\n"
+            g.write(line)
+
+    g.close()
+
+
 def get_time(string, part):
     if part == 1:
         string = string.partition(">>>")
@@ -201,10 +211,4 @@ f.close()
 
 print_times(times)
 
-g = open('times', 'w')
-
-for i in times:
-    line = str(i[0]) + " " + str(i[1]) + "\n"
-    g.write(line)
-
-g.close()
+write_times(times)