]> Frank Brehm's Git Trees - pixelpark/admin-tools.git/commitdiff
Adding pp_lib/app.py
authorFrank Brehm <frank.brehm@pixelpark.com>
Mon, 13 Mar 2017 15:25:13 +0000 (16:25 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Mon, 13 Mar 2017 15:25:13 +0000 (16:25 +0100)
pp_lib/app.py [new file with mode: 0644]
pp_lib/errors.py
pp_lib/global_version.py [new file with mode: 0644]
pp_lib/obj.py

diff --git a/pp_lib/app.py b/pp_lib/app.py
new file mode 100644 (file)
index 0000000..749947c
--- /dev/null
@@ -0,0 +1,71 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+"""
+@author: Frank Brehm
+@contact: frank.brehm@pixelpark.com
+@copyright: © 2017 by Frank Brehm, Berlin
+@summary: The module for the application object.
+"""
+from __future__ import absolute_import
+
+# Standard modules
+import sys
+import os
+import logging
+import re
+import traceback
+import textwrap
+import datetime
+
+# Third party modules
+import six
+
+import argparse
+
+# Own modules
+try:
+    from .global_version import __version__ as __global_version__
+except (SystemError, ImportError):
+    from global_version import __version__ as __global_version__
+
+try:
+    from .errors import FunctionNotImplementedError, PpAppError
+except (SystemError, ImportError):
+    from errors import FunctionNotImplementedError, PpAppError
+
+try:
+    from .common import pp, terminal_can_colors
+except (SystemError, ImportError):
+    from common import pp, terminal_can_colors
+
+try:
+    from .colored import ColoredFormatter, colorstr
+except (SystemError, ImportError):
+    from colored import ColoredFormatter, colorstr
+
+try:
+    from .obj import PpBaseObjectError, PpBaseObject
+except (SystemError, ImportError):
+    from obj import PpBaseObjectError, PpBaseObject
+
+__version__ = '0.1.0'
+LOG = logging.getLogger(__name__)
+
+
+# =============================================================================
+class PpApplication(PpBaseObject):
+    """
+    Class for the application objects.
+    """
+
+    pass
+
+# =============================================================================
+
+if __name__ == "__main__":
+
+    pass
+
+# =============================================================================
+
+# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 list
index 481af308ba0f0af82347eb22a01415931d306aea..2afec35ac2f253a51bf88af020ba231dd49c2778 100644 (file)
@@ -9,7 +9,7 @@
 import errno
 
 
-__version__ = '0.2.2'
+__version__ = '0.3.1'
 
 # =============================================================================
 class PpError(Exception):
@@ -48,6 +48,42 @@ class InvalidMailAddressError(PpError):
         return msg
 
 
+# =============================================================================
+class FunctionNotImplementedError(PpError, NotImplementedError):
+    """
+    Error class for not implemented functions.
+    """
+
+    # -------------------------------------------------------------------------
+    def __init__(self, function_name, class_name):
+        """
+        Constructor.
+
+        @param function_name: the name of the not implemented function
+        @type function_name: str
+        @param class_name: the name of the class of the function
+        @type class_name: str
+
+        """
+
+        self.function_name = function_name
+        if not function_name:
+            self.function_name = '__unkown_function__'
+
+        self.class_name = class_name
+        if not class_name:
+            self.class_name = '__unkown_class__'
+
+    # -------------------------------------------------------------------------
+    def __str__(self):
+        """
+        Typecasting into a string for error output.
+        """
+
+        msg = "Function {func}() has to be overridden in class {cls!r}."
+        return msg.format(func=self.function_name, cls=self.class_name)
+
+
 # =============================================================================
 
 if __name__ == "__main__":
diff --git a/pp_lib/global_version.py b/pp_lib/global_version.py
new file mode 100644 (file)
index 0000000..f7d71aa
--- /dev/null
@@ -0,0 +1,15 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+"""
+@author: Frank Brehm
+@contact: frank.brehm@pixelpark.com
+@copyright: © 2017 by Frank Brehm, Berlin
+@summary: Modules global version number
+"""
+
+__author__ = 'Frank Brehm <frank.brehm@pixelpark.com>'
+__contact__ = 'frank.brehm@pixelpark.com'
+__version__ = '0.1.1'
+__license__ = 'LGPL3+'
+
+# vim: fileencoding=utf-8 filetype=python ts=4
index ffd59dc470c446315085a892b96f8c09b675973c..4e776406ca0dcd081b3e27826939a22238abf4b2 100644 (file)
@@ -144,7 +144,7 @@ class PpBaseObject(object):
         if v >= 0:
             self._verbose = v
         else:
-            log.warn(_("Wrong verbose level %r, must be >= 0"), value)
+            LOG.warn(_("Wrong verbose level %r, must be >= 0"), value)
 
     # -----------------------------------------------------------
     @property
@@ -168,10 +168,10 @@ class PpBaseObject(object):
             value = os.path.expanduser(value)
         if not os.path.exists(value):
             msg = _("Base directory %r does not exists.") % (value)
-            log.error(msg)
+            LOG.error(msg)
         elif not os.path.isdir(value):
             msg = _("Base directory %r is not a directory.") % (value)
-            log.error(msg)
+            LOG.error(msg)
         else:
             self._base_dir = value
 
@@ -269,9 +269,9 @@ class PpBaseObject(object):
             has_handlers = True
 
         if has_handlers:
-            log.error(msg)
+            LOG.error(msg)
             if do_traceback:
-                log.error(traceback.format_exc())
+                LOG.error(traceback.format_exc())
 
         if not has_handlers:
             curdate = datetime.datetime.now()
@@ -312,7 +312,7 @@ class PpBaseObject(object):
             has_handlers = True
 
         if has_handlers:
-            log.info(msg)
+            LOG.info(msg)
 
         if not has_handlers:
             curdate = datetime.datetime.now()