sbsv2/raptor/test/smoke_suite/test_resources/refilter/refilter.py
author mikek
Mon, 17 May 2010 20:20:32 +0100
changeset 13 c327db0664bb
permissions -rw-r--r--
Upgrading Raptor from 2.10 to 2.13

#
# Copyright (c) 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: 
#

class Refilter:
	"""
	Refilters an existing logfile with a specified filter
	
	Parameters:
			filtermodule: 	The name of the filter file to use for refiltering
			filtername:		The name of the filter class
			logfilename: 	The logfile to be parsed
	"""
	class Dummy_raptor:
		def __init__(self, logfile, targets):
			self.logFileName = logfile
			self.quiet = False
			self.dummy = False
			self.targets = targets

	def __init__(self, filtermodule, filtername, logfilename):
		dummy_raptor = Refilter.Dummy_raptor(logfilename, [])
		
		module=__import__(filtermodule)
		self.filter=eval("module."+filtername+"()")

		self.filter.open(dummy_raptor)

	def refilter(self, inputlog):
		file=open(inputlog)

		while True:
			line=file.readline()
			if not line:
				break
			self.filter.write(line)