From c6e0e6a65686ed5fff5d476c1cfa63ca36aa8121 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Thu, 25 May 2023 13:44:10 +0200 Subject: [PATCH] Make the linter happy --- lib/pp_admintools/__init__.py | 10 +++++++-- lib/pp_admintools/app/barracuda_sync.py | 4 ++-- lib/pp_admintools/errors.py | 14 ++++++------- lib/pp_admintools/merge.py | 23 ++++++++++++++------ lib/pp_admintools/xlate.py | 28 ++++++++++++------------- 5 files changed, 48 insertions(+), 31 deletions(-) diff --git a/lib/pp_admintools/__init__.py b/lib/pp_admintools/__init__.py index a42debd..4fc4bc2 100644 --- a/lib/pp_admintools/__init__.py +++ b/lib/pp_admintools/__init__.py @@ -1,5 +1,12 @@ #!/bin/env python3 # -*- coding: utf-8 -*- +""" +@summary: The init module for the DPX admin-tools package. + +@author: Frank Brehm +@contact: frank.brehm@pixelpark.com +@copyright: © 2023 by Frank Brehm, Berlin +""" from __future__ import absolute_import # Standard modules @@ -8,7 +15,7 @@ import shutil # Own modules import fb_tools.common -__version__ = '0.8.7' +__version__ = '0.8.8' MAX_PORT_NUMBER = (2 ** 16) - 1 DEFAULT_CONFIG_DIR = 'pixelpark' @@ -24,7 +31,6 @@ def pp(value, indent=4, width=None, depth=None): @return: pretty print string @rtype: str """ - if not width: term_size = shutil.get_terminal_size((DEFAULT_TERMINAL_WIDTH, DEFAULT_TERMINAL_HEIGHT)) width = term_size.columns diff --git a/lib/pp_admintools/app/barracuda_sync.py b/lib/pp_admintools/app/barracuda_sync.py index 3646c86..1dee5bb 100644 --- a/lib/pp_admintools/app/barracuda_sync.py +++ b/lib/pp_admintools/app/barracuda_sync.py @@ -12,8 +12,8 @@ from __future__ import absolute_import # import copy import logging import re -import time import sys +import time from functools import cmp_to_key from pathlib import Path @@ -31,7 +31,7 @@ from ldap3 import MODIFY_ADD, MODIFY_DELETE, MODIFY_REPLACE from .ldap import BaseLdapApplication from ..xlate import XLATOR -__version__ = '0.9.2' +__version__ = '0.9.3' LOG = logging.getLogger(__name__) _ = XLATOR.gettext diff --git a/lib/pp_admintools/errors.py b/lib/pp_admintools/errors.py index ec57c35..7175caf 100644 --- a/lib/pp_admintools/errors.py +++ b/lib/pp_admintools/errors.py @@ -1,34 +1,34 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- """ +@summary: module for some common used error classes. + @author: Frank Brehm -@summary: module for some common used error classes """ # own modules -from fb_tools.errors import FbError, FbAppError +from fb_tools.errors import FbAppError, FbError -__version__ = '0.6.0' +__version__ = '0.6.1' # ============================================================================= class PpError(FbError): - """ - Base error class for all other self defined exceptions. - """ + """Base error class for all other self defined exceptions.""" pass # ============================================================================= class PpAppError(FbAppError): + """Base error class for all self defined exceptions in applications.""" pass # ============================================================================= -if __name__ == "__main__": +if __name__ == '__main__': pass # ============================================================================= diff --git a/lib/pp_admintools/merge.py b/lib/pp_admintools/merge.py index 2810374..864e058 100644 --- a/lib/pp_admintools/merge.py +++ b/lib/pp_admintools/merge.py @@ -1,26 +1,35 @@ #!/usr/bin/python # -*- coding: utf-8 -*- """ +@summary: A module for functions to merge different data structures. + @author: Frank Brehm @contact: frank.brehm@pixelpark.com """ import itertools -__version__ = '0.2.0' +__version__ = '0.2.1' # ============================================================================= class ZipExhausted(Exception): + """A special exception class to be used in izip_longest() on a counter overflow.""" + pass # ============================================================================= def izip_longest(*args, **kwds): - ''' + """ + Print the values of iterables alternatively in sequence. + + If one of the iterables is printed fully, the remaining values are filled + by the values assigned to fillvalue parameter. + Function izip_longest() does not exists anymore in Python3 itertools. Taken from https://docs.python.org/2/library/itertools.html#itertools.izip_longest - ''' + """ # izip_longest('ABCD', 'xy', fillvalue='-') --> Ax By C- D- fillvalue = kwds.get('fillvalue') @@ -45,9 +54,11 @@ def izip_longest(*args, **kwds): # ============================================================================= def merge_structure(a, b): - ''' + """ + Merge the given structures in a deep manner. + Taken from https://gist.github.com/saurabh-hirani/6f3f5d119076df70e0da - ''' + """ if isinstance(a, dict) and isinstance(b, dict): d = dict(a) d.update({k: merge_structure(a.get(k, None), b[k]) for k in b}) @@ -66,7 +77,7 @@ def merge_structure(a, b): # ============================================================================= -if __name__ == "__main__": +if __name__ == '__main__': pass diff --git a/lib/pp_admintools/xlate.py b/lib/pp_admintools/xlate.py index 0fc8699..066548a 100644 --- a/lib/pp_admintools/xlate.py +++ b/lib/pp_admintools/xlate.py @@ -1,25 +1,24 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- """ +@summary: The module for i18n. + +It provides translation object, usable from all other modules in this package. + @author: Frank Brehm @contact: frank@brehm-online.com @copyright: © 2023 by Frank Brehm, Berlin -@summary: The module for i18n. - It provides translation object, usable from all other - modules in this package. """ from __future__ import absolute_import, print_function # Standard modules -import logging -import gettext import copy - +import gettext +import logging try: from pathlib import Path except ImportError: from pathlib2 import Path - from distutils.version import LooseVersion # Third party modules @@ -31,7 +30,7 @@ DOMAIN = 'pp_admintools' LOG = logging.getLogger(__name__) -__version__ = '0.1.0' +__version__ = '0.1.1' __me__ = Path(__file__).resolve() __module_dir__ = __me__.parent @@ -73,6 +72,7 @@ _ = XLATOR.gettext def format_list(lst, do_repr=False, style='standard', locale=DEFAULT_LOCALE): """ Format the items in `lst` as a list. + :param lst: a sequence of items to format in to a list :param locale: the locale """ @@ -92,13 +92,13 @@ def format_list(lst, do_repr=False, style='standard', locale=DEFAULT_LOCALE): # ============================================================================= -if __name__ == "__main__": +if __name__ == '__main__': - print(_("Module directory: {!r}").format(__module_dir__)) - print(_("Base directory: {!r}").format(__base_dir__)) - print(_("Locale directory: {!r}").format(LOCALE_DIR)) - print(_("Locale domain: {!r}").format(DOMAIN)) - print(_("Found .mo-file: {!r}").format(__mo_file__)) + print(_('Module directory: {!r}').format(__module_dir__)) + print(_('Base directory: {!r}').format(__base_dir__)) + print(_('Locale directory: {!r}').format(LOCALE_DIR)) + print(_('Locale domain: {!r}').format(DOMAIN)) + print(_('Found .mo-file: {!r}').format(__mo_file__)) # ============================================================================= -- 2.39.5