lorax/src/pylorax/base.py

68 lines
1.7 KiB
Python
Raw Normal View History

2010-02-23 13:20:05 +00:00
#
# base.py
#
# Copyright (C) 2009 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Red Hat Author(s): Martin Gracik <mgracik@redhat.com>
#
from abc import ABCMeta, abstractmethod
import sys
import output
class BaseLoraxClass(object):
__metaclass__ = ABCMeta
@abstractmethod
def __init__(self):
self.output = output.LoraxOutput()
2010-12-02 11:41:14 +00:00
def pcritical(self, msg, fobj=sys.stdout):
self.output.critical(msg, fobj)
2010-02-23 13:20:05 +00:00
2010-12-02 11:41:14 +00:00
def perror(self, msg, fobj=sys.stdout):
self.output.error(msg, fobj)
2010-02-23 13:20:05 +00:00
2010-12-02 11:41:14 +00:00
def pwarning(self, msg, fobj=sys.stdout):
self.output.warning(msg, fobj)
2010-02-23 13:20:05 +00:00
2010-12-02 11:41:14 +00:00
def pinfo(self, msg, fobj=sys.stdout):
self.output.info(msg, fobj)
2010-02-23 13:20:05 +00:00
2010-12-02 11:41:14 +00:00
def pdebug(self, msg, fobj=sys.stdout):
self.output.debug(msg, fobj)
2010-11-23 11:49:02 +00:00
class DataHolder(dict):
def __init__(self, **kwargs):
dict.__init__(self)
for attr, value in kwargs.items():
self[attr] = value
2010-11-23 11:49:02 +00:00
def __getattr__(self, attr):
return self[attr]
def __setattr__(self, attr, value):
self[attr] = value
def copy(self):
return DataHolder(**dict.copy(self))