]> git.itanic.dy.fi Git - emerge-timer/commitdiff
Add preliminary support for listing all emerged packages with '-l' flag
authorEsko Kokkonen <esko.kokkonen@gmail.com>
Thu, 22 Dec 2011 11:58:03 +0000 (13:58 +0200)
committerEsko Kokkonen <esko.kokkonen@gmail.com>
Thu, 22 Dec 2011 11:58:03 +0000 (13:58 +0200)
emerge-timer.py

index 175de5c938a00c4c4f7f3e0b50a51ff0d4e91ecb..6255468a8e7051d6ed2705a5a3134cd5d5e93c65 100755 (executable)
@@ -302,6 +302,28 @@ def search_log_for_package(package_class):
 
                     package_class.add_version(version, emerge_time, start_time)
 
+def search_log_for_all_packages():
+    """Goes through the emerge.log and lists all packages in there"""
+
+    log = open_log()
+
+    all_packages = []
+
+    for line in log:
+        if ((">>>" in line) and ("emerge" in line)):
+            pack = line.partition(')')[2].strip().partition(' ')[0]
+            start_time = float(line.partition(':')[0])
+
+            all_packages.append((pack, start_time))
+
+        elif ((":::" in line) and ("completed emerge" in line)):
+            for p in all_packages:
+                if p[0] in line:
+                    stop_time = float(line.partition(':')[0])
+
+                    print("\t" + give_date(p[1]) + " >>> " + green_start + p[0] + color_stop)
+
+                    all_packages.pop(all_packages.index(p))
 
 
 def get_package(name):
@@ -484,6 +506,7 @@ Calculate emerge times from emerge log.
 Options:
 \t-c, --current \t Show time until currently compiling package finishes
 \t-p, --pretended  Calculate compile time from piped 'emerge -p' output
+\t-l, --list \t List all emerged packages
 \t-h, --help \t Show this helpscreen
 \t-q, --quiet \t Be less verbose
 \t--no-color \t Use colorless output
@@ -512,6 +535,10 @@ if __name__ == "__main__":
         if arg == "-h" or arg == "--help":
             usage()
 
+        if arg == "-l" or arg == "--list":
+            search_log_for_all_packages()
+            sys.exit(1)
+
         if arg == "-q" or arg == "--quiet":
             QUIET = True