From c1bb5e536ded49fb6f799304f0d9ac7f6b4d1d90 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Tue, 8 Apr 2008 04:54:35 +0000 Subject: Bug #197905 - Preserve order of ebuild messages even between different message types. (trunk r9726 and r9747) svn path=/main/branches/2.1.2/; revision=9748 --- pym/portage.py | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'pym') diff --git a/pym/portage.py b/pym/portage.py index fecfec3dd..0cc187da1 100644 --- a/pym/portage.py +++ b/pym/portage.py @@ -520,23 +520,40 @@ def elog_process(cpv, mysettings): except ImportError: pass - mylogfiles = listdir(mysettings["T"]+"/logging/") + path = os.path.join(mysettings["T"], "logging") + mylogfiles = None + try: + mylogfiles = os.listdir(path) + except OSError: + pass # shortcut for packages without any messages if len(mylogfiles) == 0: return # exploit listdir() file order so we process log entries in chronological order mylogfiles.reverse() all_logentries = {} - for f in mylogfiles: - msgfunction, msgtype = f.split(".") + for msgfunction in mylogfiles: if msgfunction not in portage_const.EBUILD_PHASES: writemsg("!!! can't process invalid log file: %s\n" % f, noiselevel=-1) continue if not msgfunction in all_logentries: all_logentries[msgfunction] = [] - msgcontent = open(mysettings["T"]+"/logging/"+f, "r").readlines() - all_logentries[msgfunction].append((msgtype, msgcontent)) + lastmsgtype = None + msgcontent = [] + for l in open(os.path.join(path, msgfunction), "r").readlines(): + msgtype, msg = l.split(" ", 1) + if lastmsgtype is None: + lastmsgtype = msgtype + if msgtype == lastmsgtype: + msgcontent.append(msg) + else: + if msgcontent: + all_logentries[msgfunction].append((lastmsgtype, msgcontent)) + msgcontent = [msg] + lastmsgtype = msgtype + if msgcontent: + all_logentries[msgfunction].append((lastmsgtype, msgcontent)) def filter_loglevels(logentries, loglevels): # remove unwanted entries from all logentries -- cgit v1.2.3-1-g7c22