Skip to content

Commit

Permalink
chore: black
Browse files Browse the repository at this point in the history
  • Loading branch information
gforcada committed Apr 15, 2023
1 parent 843dce3 commit e6eccbf
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 52 deletions.
2 changes: 1 addition & 1 deletion plone/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__('pkg_resources').declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__)
5 changes: 2 additions & 3 deletions plone/indexer/decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,10 @@ class indexer(adapter):

def __init__(self, *interfaces):
if len(interfaces) == 1:
interfaces += (IZCatalog, )
interfaces += (IZCatalog,)
elif len(interfaces) > 2:
raise ValueError(
'The @indexer decorator takes at most two interfaces as '
'arguments.',
"The @indexer decorator takes at most two interfaces as arguments.",
)
adapter.__init__(self, *interfaces)

Expand Down
3 changes: 1 addition & 2 deletions plone/indexer/delegate.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@

@implementer(IIndexer)
class DelegatingIndexer:
"""An indexer that delegates to a given callable
"""
"""An indexer that delegates to a given callable"""

def __init__(self, context, catalog, callable):
self.context = context
Expand Down
7 changes: 5 additions & 2 deletions plone/indexer/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@
try:
from Products.CMFCore.interfaces import IIndexableObjectWrapper
except ImportError:

class IIndexableObjectWrapper(Interface):
pass


try:
from Products.CMFCore.interfaces import IIndexableObject
except ImportError:

class IIndexableObject(Interface):
"""An object being indexed in the catalog. The indexable object
wrapper will be looked up as a multi-adapter of (object, catalog)
Expand All @@ -34,8 +38,7 @@ class IIndexer(Interface):
"""

def __call__(self):
"""Return the value to index.
"""
"""Return the value to index."""


class IDelegatingIndexableObjectWrapper(IIndexableObjectWrapper):
Expand Down
31 changes: 16 additions & 15 deletions plone/indexer/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@


class TestWrapperUpdate(unittest.TestCase):

def test_wrapper_update(self):
from plone.indexer import indexer
from zope.interface import Interface
Expand All @@ -16,9 +15,9 @@ def test_wrapper_update(self):
def my_func(obj):
"""My custom docstring."""

self.assertEqual(my_func.__doc__, 'My custom docstring.')
self.assertEqual(my_func.__module__, 'plone.indexer.tests')
self.assertEqual(my_func.__name__, 'my_func')
self.assertEqual(my_func.__doc__, "My custom docstring.")
self.assertEqual(my_func.__module__, "plone.indexer.tests")
self.assertEqual(my_func.__name__, "my_func")


class Py23DocChecker(doctest.OutputChecker):
Expand All @@ -29,17 +28,19 @@ def check_output(self, want, got, optionflags):


def test_suite():
return unittest.TestSuite([
doctest.DocFileSuite(
'README.rst',
package='plone.indexer',
setUp=testing.setUp,
tearDown=testing.tearDown,
checker=Py23DocChecker(),
return unittest.TestSuite(
[
doctest.DocFileSuite(
"README.rst",
package="plone.indexer",
setUp=testing.setUp,
tearDown=testing.tearDown,
checker=Py23DocChecker(),
),
unittest.defaultTestLoader.loadTestsFromTestCase(TestWrapperUpdate),
])
unittest.defaultTestLoader.loadTestsFromTestCase(TestWrapperUpdate),
]
)


if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
if __name__ == "__main__":
unittest.main(defaultTest="test_suite")
15 changes: 6 additions & 9 deletions plone/indexer/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,15 @@ class IndexableObjectWrapper:
"""A simple wrapper for indexable objects that will delegate to IIndexer
adapters as appropriate.
"""

__providedBy__ = WrapperSpecification()

def __init__(self, object, catalog):
self.__object = object
self.__catalog = catalog
self.__vars = {}

portal_workflow = getToolByName(catalog, 'portal_workflow', None)
portal_workflow = getToolByName(catalog, "portal_workflow", None)
if portal_workflow is not None:
self.__vars = portal_workflow.getCatalogVariablesFor(object)

Expand All @@ -58,7 +59,8 @@ def __getattr__(self, name):
# First, try to look up an indexer adapter
indexer = queryMultiAdapter(
(self.__object, self.__catalog),
IIndexer, name=name,
IIndexer,
name=name,
)
if indexer is not None:
return indexer()
Expand All @@ -78,13 +80,8 @@ def __getattr__(self, name):
# it does not!
# PythonScripts are the only way to add indexers TTW.
# If there is a PythonScript acquired, thats fine:
if (
getattr(
value_or_callable,
'meta_type',
None,
) == 'Script (Python)'
):
meta_type = getattr(value_or_callable, "meta_type", None)
if meta_type == "Script (Python)":
return value_or_callable
raise
# here we know it is a direct attribute.
Expand Down
41 changes: 21 additions & 20 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@
import os


version = '1.0.8.dev0'
description = 'Hooks to facilitate managing custom index values in Zope 2/CMF applications' # noqa
long_description = ('\n\n'.join([
open('README.rst').read(),
open('CHANGES.rst').read(),
open(os.path.join("plone", "indexer", "README.rst")).read(),

]))
version = "1.0.8.dev0"
description = "Hooks to facilitate managing custom index values in Zope 2/CMF applications" # noqa
long_description = "\n\n".join(
[
open("README.rst").read(),
open("CHANGES.rst").read(),
open(os.path.join("plone", "indexer", "README.rst")).read(),
]
)


setup(
name='plone.indexer',
name="plone.indexer",
version=version,
description=description,
long_description=long_description,
Expand All @@ -38,20 +39,20 @@
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
],
keywords='plone cmf zope catalog index',
author='Plone Foundation',
author_email='plone-developers@lists.sourceforge.net',
url='https://pypi.org/project/plone.indexer',
license='BSD',
keywords="plone cmf zope catalog index",
author="Plone Foundation",
author_email="plone-developers@lists.sourceforge.net",
url="https://pypi.org/project/plone.indexer",
license="BSD",
packages=find_packages(),
namespace_packages=['plone'],
namespace_packages=["plone"],
include_package_data=True,
zip_safe=False,
install_requires=[
'setuptools',
'zope.interface',
'zope.component',
'Products.CMFCore',
'Products.ZCatalog',
"setuptools",
"zope.interface",
"zope.component",
"Products.CMFCore",
"Products.ZCatalog",
],
)

0 comments on commit e6eccbf

Please sign in to comment.