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