]> git.itanic.dy.fi Git - emerge-timer/commitdiff
Improve if-block structure
authorEsko Kokkonen <esko.kokkonen@gmail.com>
Sat, 13 Aug 2011 15:30:22 +0000 (18:30 +0300)
committerEsko Kokkonen <esko.kokkonen@gmail.com>
Sat, 13 Aug 2011 15:30:22 +0000 (18:30 +0300)
By looking for the emerge startups earlier with if structures we can
simplify the process of searching the correct package in the log a
bit.

emerge-timer.py

index 7967574b97bf55a4f2a79ad525c12082dcd9399e..21efb4429554d007e4c52d9a8280a115c06e1c3e 100755 (executable)
@@ -192,12 +192,13 @@ def list_emerge_processes(f):
              packages.append([pack, 0])
 
     for line in f:
-        for p in packages:
-            if ((p[0] in line) and (">>>" in line) and ("emerge" in line)):
+        if ((">>>" in line) and ("emerge" in line)):
+            for p in packages:
+                if (p[0] in line):
 
-                time = float(line.partition(' ')[0].strip(":"))
-                if time > p[1]:
-                    p[1] = time
+                    time = float(line.partition(' ')[0].strip(":"))
+                    if time > p[1]:
+                        p[1] = time
 
     a = 1
     for p in packages: