Skip to content

Commit

Permalink
black and isort
Browse files Browse the repository at this point in the history
  • Loading branch information
jensens committed May 4, 2021
1 parent 206073a commit f0320bc
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 44 deletions.
5 changes: 2 additions & 3 deletions 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
create-wheel = yes
8 changes: 4 additions & 4 deletions setup.py
Expand Up @@ -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",
Expand Down Expand Up @@ -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
"""
""",
)
15 changes: 5 additions & 10 deletions src/pas/plugins/ldap/interfaces.py
Expand Up @@ -3,8 +3,7 @@


class ILDAPPlugin(Interface):
"""Marker Interface for the LDAP Plugin
"""
"""Marker Interface for the LDAP Plugin"""


class ICacheSettingsRecordProvider(Interface):
Expand All @@ -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"""
3 changes: 1 addition & 2 deletions src/pas/plugins/ldap/plonecontrolpanel/__init__.py
Expand Up @@ -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",
Expand Down
3 changes: 1 addition & 2 deletions src/pas/plugins/ldap/plonecontrolpanel/controlpanel.py
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/pas/plugins/ldap/plonecontrolpanel/exportimport.py
Expand Up @@ -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"

Expand Down
24 changes: 11 additions & 13 deletions src/pas/plugins/ldap/plugin.py
Expand Up @@ -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:
Expand All @@ -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,
)
)
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/pas/plugins/ldap/properties.py
Expand Up @@ -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('"'))
Expand Down
1 change: 1 addition & 0 deletions src/pas/plugins/ldap/testing.py
Expand Up @@ -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
Expand Down
11 changes: 5 additions & 6 deletions src/pas/plugins/ldap/tests/test_plugin.py
Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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),
(),
Expand Down

0 comments on commit f0320bc

Please sign in to comment.