import warnings import sys class Printer(object): """An abstract class that prints out warning and information messages.""" def info(self, msg): """Print out an information message. This will be used for fairly verbose information that's not normally wanted.""" raise NotImplementedError def warn(self, msg, t): """Print out a warning message of type t.""" raise NotImplementedError class SilentPrinter(Printer): """A printer that doesn't really print anything.""" def info(self, msg): pass def warn(self, msg, t): pass class NormalPrinter(SilentPrinter): """A printer that only shows warnings.""" def warn(self, msg, t): warnings.warn(msg, t, 2) class VerbosePrinter(NormalPrinter): """A printer that shows everything.""" def info(self, msg): print msg sys.stdout.flush()