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