From 5b3bfa03099f355b88e4d835ccde432752bf8d8b Mon Sep 17 00:00:00 2001 From: Esko Kokkonen Date: Thu, 22 Dec 2011 13:58:03 +0200 Subject: [PATCH] Add preliminary support for listing all emerged packages with '-l' flag --- emerge-timer.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/emerge-timer.py b/emerge-timer.py index 175de5c..6255468 100755 --- a/emerge-timer.py +++ b/emerge-timer.py @@ -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 -- 2.45.0