1*49cdfc7eSAndroid Build Coastguard Worker#!/usr/bin/env python3 2*49cdfc7eSAndroid Build Coastguard Worker# -*- coding: utf-8 -*- 3*49cdfc7eSAndroid Build Coastguard Worker 4*49cdfc7eSAndroid Build Coastguard Worker################################################################################ 5*49cdfc7eSAndroid Build Coastguard Worker## ## 6*49cdfc7eSAndroid Build Coastguard Worker## Copyright © International Business Machines Corp., 2007, 2008 ## 7*49cdfc7eSAndroid Build Coastguard Worker## ## 8*49cdfc7eSAndroid Build Coastguard Worker## This program is free software; you can redistribute it and#or modify ## 9*49cdfc7eSAndroid Build Coastguard Worker## it under the terms of the GNU General Public License as published by ## 10*49cdfc7eSAndroid Build Coastguard Worker## the Free Software Foundation; either version 2 of the License, or ## 11*49cdfc7eSAndroid Build Coastguard Worker## (at your option) any later version. ## 12*49cdfc7eSAndroid Build Coastguard Worker## ## 13*49cdfc7eSAndroid Build Coastguard Worker## This program is distributed in the hope that it will be useful, but ## 14*49cdfc7eSAndroid Build Coastguard Worker## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ## 15*49cdfc7eSAndroid Build Coastguard Worker## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ## 16*49cdfc7eSAndroid Build Coastguard Worker## for more details. ## 17*49cdfc7eSAndroid Build Coastguard Worker## ## 18*49cdfc7eSAndroid Build Coastguard Worker## You should have received a copy of the GNU General Public License ## 19*49cdfc7eSAndroid Build Coastguard Worker## along with this program; if not, write to the Free Software ## 20*49cdfc7eSAndroid Build Coastguard Worker## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ## 21*49cdfc7eSAndroid Build Coastguard Worker## ## 22*49cdfc7eSAndroid Build Coastguard Worker## NAME: parser.py ## 23*49cdfc7eSAndroid Build Coastguard Worker## ## 24*49cdfc7eSAndroid Build Coastguard Worker## DESCRIPTION: Base class for all log parsers ## 25*49cdfc7eSAndroid Build Coastguard Worker## ## 26*49cdfc7eSAndroid Build Coastguard Worker## AUTHOR: Chirag <[email protected] ## 27*49cdfc7eSAndroid Build Coastguard Worker## ## 28*49cdfc7eSAndroid Build Coastguard Worker################################################################################ 29*49cdfc7eSAndroid Build Coastguard Worker 30*49cdfc7eSAndroid Build Coastguard Workerimport sys 31*49cdfc7eSAndroid Build Coastguard Worker 32*49cdfc7eSAndroid Build Coastguard Workerclass Log: 33*49cdfc7eSAndroid Build Coastguard Worker def __init__(self,filename): 34*49cdfc7eSAndroid Build Coastguard Worker if filename: 35*49cdfc7eSAndroid Build Coastguard Worker log_file=filename 36*49cdfc7eSAndroid Build Coastguard Worker try: 37*49cdfc7eSAndroid Build Coastguard Worker self.__log_file = open(log_file, "r") 38*49cdfc7eSAndroid Build Coastguard Worker except IOError as errmsg: 39*49cdfc7eSAndroid Build Coastguard Worker sys.exit(errmsg) 40*49cdfc7eSAndroid Build Coastguard Worker 41*49cdfc7eSAndroid Build Coastguard Worker def read(self): 42*49cdfc7eSAndroid Build Coastguard Worker for line in self.__log_file.read().split("\n"): 43*49cdfc7eSAndroid Build Coastguard Worker yield line 44*49cdfc7eSAndroid Build Coastguard Worker self.__log_file.close() 45*49cdfc7eSAndroid Build Coastguard Worker 46*49cdfc7eSAndroid Build Coastguard Worker def eval(self): 47*49cdfc7eSAndroid Build Coastguard Worker pass 48