]> Frank Brehm's Git Trees - pixelpark/pp-admin-tools.git/commitdiff
Applying linter rules.
authorFrank Brehm <frank.brehm@pixelpark.com>
Thu, 1 Jun 2023 10:40:19 +0000 (12:40 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Thu, 1 Jun 2023 10:40:26 +0000 (12:40 +0200)
lib/pp_admintools/app/duplicate_attribs.py

index 95a2e06c8aeac0b3de3fbd8d6f932af70ce8848c..66618d9fe966f69607f03ec170867d67ccbd4785 100644 (file)
@@ -1,31 +1,29 @@
 # -*- coding: utf-8 -*-
 """
+@summary: An application module for evaluating duplicate attributes, which should be unique.
+
 @author: Frank Brehm
 @contact: frank.brehm@pixelpark.com
 @copyright: © 2023 by Frank Brehm, Berlin
-@summary: An application module for evaluating duplicate attributes, which should be unique
 """
 from __future__ import absolute_import
 
 # Standard modules
-import logging
 import copy
+import logging
 import re
 import sys
-
-from numbers import Number
-
 from functools import cmp_to_key
+from numbers import Number
 
 # Third party modules
 from fb_tools.xlate import format_list
 
 # Own modules
-from ..xlate import XLATOR
-
 from .ldap import BaseLdapApplication
+from ..xlate import XLATOR
 
-__version__ = '0.3.3'
+__version__ = '0.3.4'
 LOG = logging.getLogger(__name__)
 
 _ = XLATOR.gettext
@@ -53,7 +51,7 @@ class EvalDuplicateAttribsApplication(BaseLdapApplication):
 
     # -------------------------------------------------------------------------
     def __init__(self, appname=None, base_dir=None):
-        """Constructor."""
+        """Construct this application object."""
         self.uniq_attributes = copy.copy(self.default_uniq_attributes)
         self.dependend_uniq_attribs = copy.copy(self.default_dependend_uniq_attribs)
         self.result = {}
@@ -61,8 +59,8 @@ class EvalDuplicateAttribsApplication(BaseLdapApplication):
         self.connect_info = None
 
         desc = _(
-            "Evaluating all LDAP entries, which are using duplicate attributes, which "
-            "should be unique.")
+            'Evaluating all LDAP entries, which are using duplicate attributes, which '
+            'should be unique.')
 
         super(EvalDuplicateAttribsApplication, self).__init__(
             appname=appname, description=desc, base_dir=base_dir,
@@ -78,21 +76,21 @@ class EvalDuplicateAttribsApplication(BaseLdapApplication):
         eval_group.add_argument(
             '-U', '--uniq-attribs', nargs='*', dest='uniq_attribs', metavar=_('ATTRIBUTE'),
             help=_(
-                "All attribute types, which should be unique over the complete LDAP tree. "
-                "Per default the following attribute types should be unique:"
+                'All attribute types, which should be unique over the complete LDAP tree. '
+                'Per default the following attribute types should be unique:'
             ) + ' ' + format_list(self.default_uniq_attributes, do_repr=True),
         )
 
         eval_group.add_argument(
             '--dependend-attribs', nargs='*', dest='dependend_attribs', metavar=_('ATTRIBUTE'),
             help=_(
-                "All attribute types, where their uniqueness depends on an additional "
+                'All attribute types, where their uniqueness depends on an additional '
                 "LDAP filter. For instance, the attribute 'gidNumber' should be unique for "
                 "all entries, which are using the objectClass 'posixGroup'. The value "
                 "for this argument should be in the form: 'ATTRIBUTE: \"FILTER\"'. For the latter "
                 "example this would be: 'gidNumber: \"objectClass=posixGroup\"' (which "
-                "is also the default for this option). Please note, that this filter will "
-                "be wrapped by parenthesis.")
+                'is also the default for this option). Please note, that this filter will '
+                'be wrapped by parenthesis.')
         )
 
         super(EvalDuplicateAttribsApplication, self).init_arg_parser()
@@ -104,16 +102,13 @@ class EvalDuplicateAttribsApplication(BaseLdapApplication):
 
     # -------------------------------------------------------------------------
     def post_init(self):
-        """
-        Method to execute before calling run().
-        """
-
+        """Execute this before calling run()."""
         super(EvalDuplicateAttribsApplication, self).post_init()
 
         pat_dep_attribs = r'^(?P<attrib>[a-z](?:[a-z0-9-]*[a-z0-9])?):\s*'
         pat_dep_attribs += r'(?P<quote>[\'"])?(?P<filter>.+)(?P=quote)?$'
         if self.verbose > 2:
-            LOG.debug("Pattern for verifying dependend unique attributes: {!r}".format(
+            LOG.debug('Pattern for verifying dependend unique attributes: {!r}'.format(
                 pat_dep_attribs))
         re_dep_attribs = re.compile(pat_dep_attribs, re.IGNORECASE)
 
@@ -133,7 +128,7 @@ class EvalDuplicateAttribsApplication(BaseLdapApplication):
                     dep_attribs[attr_name] = attr_filter
                 else:
                     wrong_attribs = True
-                    msg = _("Wrong definition for a filter dependend unique attribute given:")
+                    msg = _('Wrong definition for a filter dependend unique attribute given:')
                     msg += ' {!r}'.format(attrib)
                     LOG.error(msg)
             if wrong_attribs:
@@ -148,7 +143,7 @@ class EvalDuplicateAttribsApplication(BaseLdapApplication):
     # -------------------------------------------------------------------------
     def _run(self):
 
-        LOG.info("And here we go ...")
+        LOG.info('And here we go ...')
 
         for attrib in self.uniq_attributes:
             self.empty_line()
@@ -218,12 +213,12 @@ class EvalDuplicateAttribsApplication(BaseLdapApplication):
                     print(' * {}'.format(dn))
                 self.empty_line()
         else:
-            print(_("No duplicates for attribute {!r} found.").format(attrib))
+            print(_('No duplicates for attribute {!r} found.').format(attrib))
             self.empty_line()
 
 
 # =============================================================================
-if __name__ == "__main__":
+if __name__ == '__main__':
 
     pass