From: Frank Brehm Date: Wed, 18 May 2022 12:08:48 +0000 (+0200) Subject: Applying flake 8 rules X-Git-Tag: 0.4.2^2~5^2~4 X-Git-Url: https://git.uhu-banane.net/?a=commitdiff_plain;h=7c0e8742faaa934ce35f2079b7a8cf38c04b5545;p=pixelpark%2Fpp-admin-tools.git Applying flake 8 rules --- diff --git a/lib/pp_admintools/ldap_app.py b/lib/pp_admintools/ldap_app.py index 34a2746..bf9b561 100644 --- a/lib/pp_admintools/ldap_app.py +++ b/lib/pp_admintools/ldap_app.py @@ -9,8 +9,6 @@ from __future__ import absolute_import # Standard modules import logging -import copy -import pipes import os import argparse @@ -19,9 +17,7 @@ try: except ImportError: from pathlib2 import Path -## Third party modules -from fb_tools.common import pp - +# Third party modules from fb_tools.cfg_app import FbConfigApplication from fb_tools.errors import FbAppError @@ -33,14 +29,14 @@ from .xlate import XLATOR from . import MAX_PORT_NUMBER, DEFAULT_CONFIG_DIR -from .xlate import XLATOR - -from .argparse_actions import PortOptionAction +# from .argparse_actions import PortOptionAction -from .ldap_config import LdapConfigError, LdapConnectionInfo, LdapConfiguration -from .ldap_config import DEFAULT_PORT_LDAP, DEFAULT_PORT_LDAPS, DEFAULT_TIMEOUT, MAX_TIMEOUT +# from .ldap_config import LdapConfigError +from .ldap_config import LdapConnectionInfo, LdapConfiguration +# rom .ldap_config import DEFAULT_PORT_LDAP, DEFAULT_PORT_LDAPS +from .ldap_config import DEFAULT_TIMEOUT, MAX_TIMEOUT -__version__ = '0.1.1' +__version__ = '0.1.2' LOG = logging.getLogger(__name__) _ = XLATOR.gettext @@ -57,7 +53,7 @@ class LdapAppError(FbAppError): class PasswordFileOptionAction(argparse.Action): # ------------------------------------------------------------------------- - def __init__(self, option_strings, must_exists=True, *args, **kwargs): + def __init__(self, option_strings, must_exists=True, *args, **kwargs): self.must_exists = bool(must_exists) @@ -102,7 +98,7 @@ class LdapPortOptionAction(argparse.Action): def __call__(self, parser, namespace, given_port, option_string=None): try: - port = int(given_port): + port = int(given_port) if port <= 0 or port > MAX_PORT_NUMBER: msg = _( "a port number must be greater than zero and less " @@ -129,7 +125,7 @@ class TimeoutOptionAction(argparse.Action): def __call__(self, parser, namespace, given_timeout, option_string=None): try: - timeout = int(given_timeout): + timeout = int(given_timeout) if timeout <= 0 or timeout > MAX_TIMEOUT: msg = _( "a timeout must be greater than zero and less " @@ -216,7 +212,6 @@ class BaseLdapApplication(FbConfigApplication): return res - # ------------------------------------------------------------------------- def init_arg_parser(self): """ @@ -248,7 +243,8 @@ class BaseLdapApplication(FbConfigApplication): ldap_group.add_argument( '--ssl', '--ldaps', '--ldap-ssl', dest="ldap_ssl", action="store_true", - help=_("Use ldaps to connect to the LDAP server. Default: {}").format(ldap_ssl_str), + help=_("Use ldaps to connect to the LDAP server. Default: {}").format( + ldap_ssl_str), ) ldap_group.add_argument( diff --git a/lib/pp_admintools/ldap_config.py b/lib/pp_admintools/ldap_config.py index 5368abc..9219a57 100644 --- a/lib/pp_admintools/ldap_config.py +++ b/lib/pp_admintools/ldap_config.py @@ -17,8 +17,8 @@ import re # Third party modules # Own modules - -from fb_tools.common import is_sequence, pp, to_bool +# from fb_tools.common import pp +from fb_tools.common import is_sequence, to_bool # from .config import ConfigError, BaseConfiguration from fb_tools.multi_config import MultiConfigError, BaseMultiConfig @@ -26,12 +26,11 @@ from fb_tools.multi_config import DEFAULT_ENCODING from fb_tools.obj import FbGenericBaseObject, FbBaseObject -from . import __version__ as GLOBAL_VERSION from . import MAX_PORT_NUMBER, DEFAULT_CONFIG_DIR from .xlate import XLATOR -__version__ = '0.2.2' +__version__ = '0.2.3' LOG = logging.getLogger(__name__) _ = XLATOR.gettext @@ -236,9 +235,9 @@ class LdapConnectionInfo(FbBaseObject): def __copy__(self): new = self.__class__( - appname=appname, verbose=verbose, base_dir=base_dir, host=host, use_ldaps=use_ldaps, - port=port, base_dn=base_dn, bind_dn=bind_dn, bind_pw=bind_pw, - initialized=initialized) + appname=self.appname, verbose=self.verbose, base_dir=self.base_dir, host=self.host, + use_ldaps=self.use_ldaps, port=self.port, base_dn=self.base_dn, bind_dn=self.bind_dn, + bind_pw=self.bind_pw, initialized=self.initialized) return new @@ -363,17 +362,17 @@ class LdapConfiguration(BaseMultiConfig): def _eval_ldap_timeout(self, value): timeout = DEFAULT_TIMEOUT + msg_invalid = _("Value {!r} for a timeout is invalid.") try: timeout = int(value) except (ValueError, TypeError) as e: - msg = _("Value {!r} for a timeout is invalid:").format(value) - msg += ' ' + str(e) + msg = msg_invalid.format(value) + msg += ': ' + str(e) LOG.error(msg) return if timeout <= 0 or timeout > MAX_TIMEOUT: - msg = _("Value {!r} for a timeout is invalid:").format(value) - msg += ' ' + str(e) + msg = msg_invalid.format(value) LOG.error(msg) return @@ -416,7 +415,6 @@ class LdapConfiguration(BaseMultiConfig): continue if port <= 0 or port > MAX_PORT_NUMBER: msg = msg_invalid.format(val=value, sec=section_name, what='port') - msg += ' ' + str(e) LOG.error(msg) continue connection.port = port