Source code for pylorax.base

#
# 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 pylorax.output as output


[docs]class BaseLoraxClass(object): __metaclass__ = ABCMeta @abstractmethod def __init__(self): self.output = output.LoraxOutput()
[docs] def pcritical(self, msg, fobj=sys.stdout): self.output.critical(msg, fobj)
[docs] def perror(self, msg, fobj=sys.stdout): self.output.error(msg, fobj)
[docs] def pwarning(self, msg, fobj=sys.stdout): self.output.warning(msg, fobj)
[docs] def pinfo(self, msg, fobj=sys.stdout): self.output.info(msg, fobj)
[docs] def pdebug(self, msg, fobj=sys.stdout): self.output.debug(msg, fobj)
[docs]class DataHolder(dict): def __init__(self, **kwargs): dict.__init__(self) for attr, value in kwargs.items(): self[attr] = value def __getattr__(self, attr): return self[attr] def __setattr__(self, attr, value): self[attr] = value
[docs] def copy(self): return DataHolder(**dict.copy(self))