From: Frank Brehm Date: Thu, 11 May 2017 08:56:27 +0000 (+0200) Subject: Defining some basic exceptions in lib/trace_maillog/any_uncompress_file.py X-Git-Url: https://git.uhu-banane.org/?a=commitdiff_plain;h=0c8e7b4081cdeb969b222bd2ff510daee14c9ab8;p=pixelpark%2Ftrace-maillog.git Defining some basic exceptions in lib/trace_maillog/any_uncompress_file.py --- diff --git a/lib/trace_maillog/any_uncompress_file.py b/lib/trace_maillog/any_uncompress_file.py index 2ca7ff4..584064e 100644 --- a/lib/trace_maillog/any_uncompress_file.py +++ b/lib/trace_maillog/any_uncompress_file.py @@ -4,7 +4,7 @@ @author: Frank Brehm @contact: frank.brehm@pixelpark.com @copyright: © 2017 by Frank Brehm, Berlin -@summary: The module for e AnyUmpressFile class +@summary: The module for a AnyUmpressFile class """ from __future__ import absolute_import @@ -30,11 +30,46 @@ except ImportError: # Third party modules import six +__version__ = '0.1.0' + + +# ============================================================================= +class BaseAnyUncompressError(Exception): + """Base class for all exceptions defined in this module.""" + pass + +# ============================================================================= +class InvalidCompressionError(BaseAnyUncompressError, NotImplementedError): + """Special exception class for not implemented compression types.""" + + # ------------------------------------------------------------------------- + def __init__(self, compress_type, filename=None): + + self.compress_type = compress_type + self.filename = filename + + # ------------------------------------------------------------------------- + def __str__(self): + + if self.filename: + msg = "Unimplemented compression type {t!r} on file {f!r}.".format( + t=self.compress_type, f=self.filename) + else: + msg = "Unimplemented compression type {!r}.".format(self.compress_type) + return msg + + +# ============================================================================= +class AnyUmpressFile(object): + + pass + + # ============================================================================= -class InvalidCompressionError(NotImplementedError): +if __name__ == "__main__": pass # ============================================================================= -class AnyUmpressFile(file): +# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4