diff -r 7c4a911dc066 -r 541af5ee3ed9 sbsv2/raptor/bin/raptorlog.py --- a/sbsv2/raptor/bin/raptorlog.py Fri Aug 13 14:59:05 2010 +0300 +++ b/sbsv2/raptor/bin/raptorlog.py Wed Aug 18 17:23:33 2010 +0300 @@ -1,71 +1,71 @@ -# -# Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). -# All rights reserved. -# This component and the accompanying materials are made available -# under the terms of the License "Eclipse Public License v1.0" -# which accompanies this distribution, and is available -# at the URL "http://www.eclipse.org/legal/epl-v10.html". -# -# Initial Contributors: -# Nokia Corporation - initial contribution. -# -# Contributors: -# -# Description: -# - - Raptor log parsing utilities. - - Line-by-line based log reporting. -""" - -import re - - -class LogItem(object): - keep = False - def __init__(self, name, pattern, keep=False, subpattern=None): - self.name = name - self.matcher = re.compile(pattern, re.I) - self.count = 0 - - if subpattern: - self.subpattern = re.compile(subpattern,re.I) - else: - self.subpattern = None - - if keep and LogItem.keep: - self.keep = {} - else: - self.keep = None - - self.subpatterncount = 0 - - def xml(self): - xml = "" - - xml += ">\n" - - index = self.keep.keys() - index.sort(cmp=lambda y,x: self.keep[x] - self.keep[y]) - for i in index: - xml += "\n" - - return xml + "" - - def match(self, line): - result = self.matcher.search(line) - if result != None: - if self.keep != None: - try: - self.keep[result.group()] += 1 - except: - self.keep[result.group()] = 1 - if self.subpattern != None: - self.subpatterncount += len(self.subpattern.findall(line)) - for i in self.subpattern.findall(line): - print i - self.count += 1 - +# +# Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of the License "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# + + Raptor log parsing utilities. + + Line-by-line based log reporting. +""" + +import re + + +class LogItem(object): + keep = False + def __init__(self, name, pattern, keep=False, subpattern=None): + self.name = name + self.matcher = re.compile(pattern, re.I) + self.count = 0 + + if subpattern: + self.subpattern = re.compile(subpattern,re.I) + else: + self.subpattern = None + + if keep and LogItem.keep: + self.keep = {} + else: + self.keep = None + + self.subpatterncount = 0 + + def xml(self): + xml = "" + + xml += ">\n" + + index = self.keep.keys() + index.sort(cmp=lambda y,x: self.keep[x] - self.keep[y]) + for i in index: + xml += "\n" + + return xml + "" + + def match(self, line): + result = self.matcher.search(line) + if result != None: + if self.keep != None: + try: + self.keep[result.group()] += 1 + except: + self.keep[result.group()] = 1 + if self.subpattern != None: + self.subpatterncount += len(self.subpattern.findall(line)) + for i in self.subpattern.findall(line): + print i + self.count += 1 +