Skip to content

Commit

Permalink
Lint the code.
Browse files Browse the repository at this point in the history
Add support for Python 3.8 and 3.9.
  • Loading branch information
Michael Howitz committed Jan 27, 2021
1 parent ec4edb0 commit 969e22a
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 36 deletions.
2 changes: 1 addition & 1 deletion CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Changes
1.2 (unreleased)
================

- Nothing changed yet.
- Add support for Python 3.8 and 3.9.


1.1 (2018-11-07)
Expand Down
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def read_file(*args):
with open(path, 'r') as f:
return f.read() + '\n\n'


setup(
name='zc.sourcefactory',
version='1.2.dev0',
Expand Down Expand Up @@ -56,6 +57,8 @@ def read_file(*args):
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: Implementation :: CPython',
'Natural Language :: English',
'Operating System :: OS Independent',
Expand Down
8 changes: 1 addition & 7 deletions src/zc/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
# This directory is a Python namespace package.
try:
import pkg_resources
pkg_resources.declare_namespace(__name__)
except ImportError:
import pkgutil
__path__ = pkgutil.extend_path(__path__, __name__)
__import__('pkg_resources').declare_namespace(__name__) # pragma: no cover
1 change: 1 addition & 0 deletions src/zc/sourcefactory/adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import zope.component
import zc.sourcefactory.source


@zope.interface.implementer(zope.schema.interfaces.ISourceQueriables)
@zope.component.adapter(zc.sourcefactory.source.FactoredSource)
def getSourceQueriables(factored_source):
Expand Down
1 change: 1 addition & 0 deletions src/zc/sourcefactory/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import zc.sourcefactory.factories
import zc.sourcefactory.policies


class BasicSourceFactory(zc.sourcefactory.factories.BasicSourceFactory,
zc.sourcefactory.policies.BasicSourcePolicy):
"""Basic source factory implementation including a factory and the
Expand Down
4 changes: 2 additions & 2 deletions src/zc/sourcefactory/browser/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@

@zope.interface.implementer(zope.browser.interfaces.ITerms)
class MappedTerms(object):
"""A terms implementation that knows how to handle a source that was
"""A terms implementation that knows how to handle a source that was
created through a source factory.
"""

zope.component.adapts(zc.sourcefactory.mapping.ValueMappingSource,
zope.publisher.interfaces.browser.IBrowserRequest)
zope.publisher.interfaces.browser.IBrowserRequest)

def __init__(self, source, request):
self.base = zope.component.getMultiAdapter(
Expand Down
15 changes: 8 additions & 7 deletions src/zc/sourcefactory/browser/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@

from zc.sourcefactory.tests import setUp, tearDown, checker


def test_suite():
return unittest.TestSuite((
doctest.DocFileSuite(
'token.txt', setUp=setUp, tearDown=tearDown,
checker=checker, optionflags=doctest.ELLIPSIS),
doctest.DocFileSuite(
'README.txt', setUp=setUp, tearDown=tearDown,
checker=checker, optionflags=doctest.ELLIPSIS),
))
doctest.DocFileSuite(
'token.txt', setUp=setUp, tearDown=tearDown,
checker=checker, optionflags=doctest.ELLIPSIS),
doctest.DocFileSuite(
'README.txt', setUp=setUp, tearDown=tearDown,
checker=checker, optionflags=doctest.ELLIPSIS),
))
1 change: 1 addition & 0 deletions src/zc/sourcefactory/browser/token.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

PY3 = sys.version_info[0] == 3


@zope.component.adapter(bytes)
@zope.interface.implementer(zc.sourcefactory.interfaces.IToken)
def fromString(value):
Expand Down
4 changes: 2 additions & 2 deletions src/zc/sourcefactory/contextual.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@


class BasicContextualSourceFactory(
zc.sourcefactory.factories.ContextualSourceFactory,
zc.sourcefactory.policies.BasicContextualSourcePolicy):
zc.sourcefactory.factories.ContextualSourceFactory,
zc.sourcefactory.policies.BasicContextualSourcePolicy):
"""Abstract base implementation for a basic contextual source factory."""
4 changes: 3 additions & 1 deletion src/zc/sourcefactory/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import zope.interface
import zope.schema.interfaces


class ISourceFactory(zope.interface.Interface):

def __call__():
Expand Down Expand Up @@ -133,10 +134,11 @@ def filterValue(context, value):

# Standard combined policies


class ISourcePolicy(ITokenPolicy, ITermPolicy, IValuePolicy):
pass


class IContextualSourcePolicy(
ITokenPolicy, IContextualTermPolicy, IContextualValuePolicy):
ITokenPolicy, IContextualTermPolicy, IContextualValuePolicy):
pass
13 changes: 9 additions & 4 deletions src/zc/sourcefactory/policies.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@
try:
unicode
except NameError:
# Py3: Define unicode
# PY3: Define unicode
unicode = str

# Term policies


@zope.interface.implementer(zc.sourcefactory.interfaces.ITermPolicy)
class BasicTermPolicy(object):
"""A basic term policy.
Expand All @@ -54,7 +55,8 @@ def getTitle(self, value):
if md:
title = md.title
else:
title = value.decode() if isinstance(value, bytes) else unicode(value)
title = value.decode() if isinstance(value,
bytes) else unicode(value)
return title


Expand Down Expand Up @@ -156,8 +158,9 @@ class BasicValuePolicy(object):
def filterValue(self, value):
return True


@zope.interface.implementer(
zc.sourcefactory.interfaces.IContextualValuePolicy)
zc.sourcefactory.interfaces.IContextualValuePolicy)
class BasicContextualValuePolicy(BasicValuePolicy):
"""An abstract basic value policy.
Expand All @@ -177,7 +180,9 @@ class BasicSourcePolicy(BasicValuePolicy, BasicTokenPolicy, BasicTermPolicy):


class BasicContextualSourcePolicy(
BasicContextualValuePolicy, BasicContextualTokenPolicy, BasicContextualTermPolicy):
BasicContextualValuePolicy,
BasicContextualTokenPolicy,
BasicContextualTermPolicy):
pass


Expand Down
27 changes: 15 additions & 12 deletions src/zc/sourcefactory/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
# Python 3 adds module name to exceptions.
(re.compile("zope.security.interfaces.ForbiddenAttribute"),
r"ForbiddenAttribute"),
])
])


class ConnectionStub(object):

Expand All @@ -56,7 +57,7 @@ def __call__(self, obj):
return self

def add(self, obj):
self._id +=1
self._id += 1
obj._p_oid = ZODB.utils.p64(self._id)


Expand All @@ -67,18 +68,20 @@ def setUp(test):
ConnectionStub(), (IFolder,), ZODB.interfaces.IConnection)
test.globs['rootFolder'] = folder.rootFolder()


def tearDown(test):
testing.tearDown(test)


def test_suite():
return unittest.TestSuite((
doctest.DocFileSuite(
'README.txt'),
doctest.DocFileSuite(
'mapping.txt'),
doctest.DocFileSuite(
'constructors.txt'),
doctest.DocFileSuite(
'adapters.txt', setUp=setUp, tearDown=tearDown,
optionflags=doctest.ELLIPSIS),
))
doctest.DocFileSuite(
'README.txt'),
doctest.DocFileSuite(
'mapping.txt'),
doctest.DocFileSuite(
'constructors.txt'),
doctest.DocFileSuite(
'adapters.txt', setUp=setUp, tearDown=tearDown,
optionflags=doctest.ELLIPSIS),
))

0 comments on commit 969e22a

Please sign in to comment.