diff --git a/setup.cfg b/setup.cfg index b64af7f..6a52b8a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,12 +1,11 @@ [isort] # https://github.com/timothycrosley/isort/wiki/isort-Settings # https://github.com/plone/plone.recipe.codeanalysis +profile = black force_alphabetical_sort=True force_single_line = True lines_after_imports = 2 line_length = 200 -not_skip = __init__.py -skip = bootstrap-buildout.py [zest.releaser] -create-wheel = yes \ No newline at end of file +create-wheel = yes diff --git a/setup.py b/setup.py index c5d06fc..8edc2c9 100644 --- a/setup.py +++ b/setup.py @@ -33,7 +33,7 @@ "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python", - "Topic :: System :: Systems Administration :: Authentication/Directory :: LDAP" + "Topic :: System :: Systems Administration :: Authentication/Directory :: LDAP", ], keywords="zope pas plone ldap authentication plugin", author="BlueDynamics Alliance", @@ -71,14 +71,14 @@ "zope.globalrequest", "zope.i18nmessageid", "zope.interface", - "zope.traversing" + "zope.traversing", ], extras_require={ "test": ["plone.testing", "zope.configuration"], - "plone": ["Plone"] + "plone": ["Plone"], }, entry_points=""" [z3c.autoinclude.plugin] target = plone - """ + """, ) diff --git a/src/pas/plugins/ldap/interfaces.py b/src/pas/plugins/ldap/interfaces.py index 4dff6da..c96985a 100644 --- a/src/pas/plugins/ldap/interfaces.py +++ b/src/pas/plugins/ldap/interfaces.py @@ -3,8 +3,7 @@ class ILDAPPlugin(Interface): - """Marker Interface for the LDAP Plugin - """ + """Marker Interface for the LDAP Plugin""" class ICacheSettingsRecordProvider(Interface): @@ -17,17 +16,13 @@ class ICacheSettingsRecordProvider(Interface): class IPluginCacheHandler(Interface): - """Handles caching of the node trees used in the PAS Plugin - """ + """Handles caching of the node trees used in the PAS Plugin""" def get(): - """the cached value or VALUE_NOT_CACHED - """ + """the cached value or VALUE_NOT_CACHED""" def set(value): - """sets a value in the cache - """ + """sets a value in the cache""" def invalidate(): - """removes a value from the cache - """ + """removes a value from the cache""" diff --git a/src/pas/plugins/ldap/plonecontrolpanel/__init__.py b/src/pas/plugins/ldap/plonecontrolpanel/__init__.py index 8e62c87..c2af1ad 100644 --- a/src/pas/plugins/ldap/plonecontrolpanel/__init__.py +++ b/src/pas/plugins/ldap/plonecontrolpanel/__init__.py @@ -5,8 +5,7 @@ @implementer(INonInstallable) class HiddenProfiles(object): - """This hides zope2 profile from the quick installer tool and plone cpanel - """ + """This hides zope2 profile from the quick installer tool and plone cpanel""" _hidden = [ u"pas.plugins.ldap:default", diff --git a/src/pas/plugins/ldap/plonecontrolpanel/controlpanel.py b/src/pas/plugins/ldap/plonecontrolpanel/controlpanel.py index 6674265..d8daccc 100644 --- a/src/pas/plugins/ldap/plonecontrolpanel/controlpanel.py +++ b/src/pas/plugins/ldap/plonecontrolpanel/controlpanel.py @@ -24,8 +24,7 @@ def next(self, request): @property def plugin(self): - """ControlPanel config is only for GS installed 'pasldap' plugin - """ + """ControlPanel config is only for GS installed 'pasldap' plugin""" portal = getPortal() aclu = portal.acl_users plugin = aclu.pasldap diff --git a/src/pas/plugins/ldap/plonecontrolpanel/exportimport.py b/src/pas/plugins/ldap/plonecontrolpanel/exportimport.py index 91d7378..43eb9aa 100644 --- a/src/pas/plugins/ldap/plonecontrolpanel/exportimport.py +++ b/src/pas/plugins/ldap/plonecontrolpanel/exportimport.py @@ -45,8 +45,7 @@ def export_settings(context): @implementer(IBody) class LDAPPluginXMLAdapter(XMLAdapterBase): - """import pas groups from ldap config. - """ + """import pas groups from ldap config.""" name = "ldapsettings" diff --git a/src/pas/plugins/ldap/plugin.py b/src/pas/plugins/ldap/plugin.py index ed0563c..b2fd2cb 100644 --- a/src/pas/plugins/ldap/plugin.py +++ b/src/pas/plugins/ldap/plugin.py @@ -44,8 +44,7 @@ def manage_addLDAPPlugin(dispatcher, id, title="", RESPONSE=None, **kw): - """Create an instance of a LDAP Plugin. - """ + """Create an instance of a LDAP Plugin.""" ldapplugin = LDAPPlugin(id, title, **kw) dispatcher._setObject(ldapplugin.getId(), ldapplugin) if RESPONSE is not None: @@ -68,7 +67,9 @@ def _wrapper(self, *args, **kwargs): if waiting < LDAP_ERROR_LOG_TIMEOUT: logger.debug( "{0}: retry wait {1:0.5f} of {2:0.0f}s -> {3}".format( - prefix, waiting, LDAP_ERROR_LOG_TIMEOUT, + prefix, + waiting, + LDAP_ERROR_LOG_TIMEOUT, self._v_ldaperror_msg, ) ) @@ -119,8 +120,7 @@ def _wrapper(self, *args, **kwargs): plonepas_interfaces.plugins.IUserManagement, ) class LDAPPlugin(BasePlugin): - """Glue layer for making node.ext.ldap available to PAS. - """ + """Glue layer for making node.ext.ldap available to PAS.""" security = ClassSecurityInfo() meta_type = "LDAP Plugin" @@ -240,7 +240,7 @@ def authenticateCredentials(self, credentials): def enumerateGroups( self, id=None, exact_match=False, sort_by=None, max_results=None, **kw ): - """ -> ( group_info_1, ... group_info_N ) + """-> ( group_info_1, ... group_info_N ) o Return mappings for groups matching the given criteria. @@ -440,12 +440,12 @@ def getRolesForPrincipal(self, principal, request=None): if not users: return default if self.enumerateUsers(id=principal.getId()): - return ('Member', ) + return ("Member",) return default @security.private def updateUser(self, user_id, login_name): - """ Update the login name of the user with id user_id. + """Update the login name of the user with id user_id. The plugin must return True (or any truth value) to indicate a successful update, also when no update was needed. @@ -593,7 +593,7 @@ def deleteUser(self, user_id): # @security.private def doAddUser(self, login, password): - """ Add a user record to a User Manager, with the given login + """Add a user record to a User Manager, with the given login and password o Return a Boolean indicating whether a user was added or not @@ -632,8 +632,7 @@ def doDeleteUser(self, login): # @security.public def allowDeletePrincipal(self, id): - """True if this plugin can delete a certain user/group. - """ + """True if this plugin can delete a certain user/group.""" # XXX return False @@ -744,8 +743,7 @@ def getGroupMembers(self, group_id): # @security.public def allowPasswordSet(self, id): - """True if this plugin can set the password of a certain user. - """ + """True if this plugin can set the password of a certain user.""" users = self.users if not users: return False diff --git a/src/pas/plugins/ldap/properties.py b/src/pas/plugins/ldap/properties.py index 31ab3c5..3ac4720 100644 --- a/src/pas/plugins/ldap/properties.py +++ b/src/pas/plugins/ldap/properties.py @@ -137,8 +137,8 @@ def fetch(name, default=UNSET): # we expect to always have the id key mapped under the same name in the # propertysheet. this would be set implicit on LDAPPrincipal init, but # to avoid a write on read, we do it here. - if users.attrmap['id'] not in users.attrmap: - users.attrmap[users.attrmap['id']] = users.attrmap['id'] + if users.attrmap["id"] not in users.attrmap: + users.attrmap[users.attrmap["id"]] = users.attrmap["id"] users.scope = fetch("users.scope") if users.scope is not UNSET: users.scope = int(users.scope.strip('"')) diff --git a/src/pas/plugins/ldap/testing.py b/src/pas/plugins/ldap/testing.py index 3ea5dc8..28b7f32 100644 --- a/src/pas/plugins/ldap/testing.py +++ b/src/pas/plugins/ldap/testing.py @@ -19,6 +19,7 @@ from zope.interface import implementer from zope.interface import Interface + try: # plone 5.x with PlonePAS >=5.0 from Products.PlonePAS.setuphandlers import migrate_root_uf diff --git a/src/pas/plugins/ldap/tests/test_plugin.py b/src/pas/plugins/ldap/tests/test_plugin.py index 7baeed2..0da33f3 100644 --- a/src/pas/plugins/ldap/tests/test_plugin.py +++ b/src/pas/plugins/ldap/tests/test_plugin.py @@ -14,9 +14,7 @@ def pas(self): return self.layer["app"].acl_users def test_pas_installed(self): - from Products.PluggableAuthService.PluggableAuthService import ( - PluggableAuthService, - ) + from Products.PluggableAuthService.PluggableAuthService import PluggableAuthService self.assertIsInstance(self.pas, PluggableAuthService) @@ -216,6 +214,7 @@ def test_IDeleteCapability(self): def test_pickable_propertysheet(self): """In order to cache propertysheets it must be picklable""" from Acquisition import aq_base + import pickle self.assertGreater(len(pickle.dumps(aq_base(self.ldap))), 170) @@ -319,12 +318,12 @@ def test_IUserManagement(self): self.assertFalse(self.ldap.doDeleteUser("uid0")) def test_IRolesPlugin(self): - ldap_user = PloneUser('uid0', login='cn0') + ldap_user = PloneUser("uid0", login="cn0") self.assertEqual( self.ldap.getRolesForPrincipal(ldap_user), - ('Member', ), + ("Member",), ) - other_user = PloneUser('unknown', login='other') + other_user = PloneUser("unknown", login="other") self.assertEqual( self.ldap.getRolesForPrincipal(other_user), (),