From 0c8e7b4081cdeb969b222bd2ff510daee14c9ab8 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Thu, 11 May 2017 10:56:27 +0200 Subject: [PATCH] Defining some basic exceptions in lib/trace_maillog/any_uncompress_file.py --- lib/trace_maillog/any_uncompress_file.py | 41 ++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 3 deletions(-) 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 -- 2.39.5