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