Skip to content

Commit

Permalink
Lint the code.
Browse files Browse the repository at this point in the history
* Add support for Python 3.7, 3.8 and 3.9.
* Drop support for Python 3.4.
  • Loading branch information
Michael Howitz committed Jan 29, 2021
1 parent 108f77d commit c49ce5e
Show file tree
Hide file tree
Showing 18 changed files with 114 additions and 94 deletions.
6 changes: 4 additions & 2 deletions CHANGES.rst
Expand Up @@ -2,10 +2,12 @@
CHANGES
=========

4.1.1 (unreleased)
4.2.0 (unreleased)
==================

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

- Drop support for Python 3.4.


4.1.0 (2017-07-12)
Expand Down
19 changes: 14 additions & 5 deletions setup.py
Expand Up @@ -22,20 +22,22 @@
import os
from setuptools import setup, find_packages


def read(*rnames):
with open(os.path.join(os.path.dirname(__file__), *rnames)) as f:
return f.read()


setup(name='zope.app.onlinehelp',
version='4.1.1.dev0',
author='Zope Corporation and Contributors',
version='4.2.0.dev0',
author='Zope Foundation and Contributors',
author_email='zope-dev@zope.org',
description='Framework for Context-Sensitive Help Pages',
long_description=(
read('README.rst')
+ '\n\n' +
read('CHANGES.rst')
),
),
keywords="zope3 online help",
classifiers=[
'Development Status :: 5 - Production/Stable',
Expand All @@ -46,9 +48,11 @@ def read(*rnames):
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'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',
'Programming Language :: Python :: Implementation :: PyPy',
'Natural Language :: English',
Expand Down Expand Up @@ -105,7 +109,12 @@ def read(*rnames):
'zope.testing',
'zope.testrunner',
],
'docs': [
'Sphinx',
'repoze.sphinx.autointerface',
'sphinx_rtd_theme',
]
},
include_package_data=True,
zip_safe=False,
)
)
2 changes: 1 addition & 1 deletion src/zope/__init__.py
@@ -1 +1 @@
__import__('pkg_resources').declare_namespace(__name__) # pragma: no cover
__import__('pkg_resources').declare_namespace(__name__) # pragma: no cover
2 changes: 1 addition & 1 deletion src/zope/app/__init__.py
@@ -1 +1 @@
__import__('pkg_resources').declare_namespace(__name__) # pragma: no cover
__import__('pkg_resources').declare_namespace(__name__) # pragma: no cover
9 changes: 6 additions & 3 deletions src/zope/app/onlinehelp/__init__.py
Expand Up @@ -32,9 +32,10 @@

# Global Online Help Instance
path = os.path.join(os.path.dirname(__file__),
'help', 'welcome.stx')
'help', 'welcome.stx')
globalhelp = OnlineHelp('Online Help', path)


class _TraversedOnlineHelpProxy(ProxyBase):
"""
A proxy around the globalhelp object that is returned when we
Expand Down Expand Up @@ -83,7 +84,8 @@ def getTopicFor(obj, view=None):
>>> import os
>>> from zope.app.onlinehelp.tests.test_onlinehelp import testdir
>>> from zope.app.onlinehelp.tests.test_onlinehelp import I1, Dummy1, Dummy2
>>> from zope.app.onlinehelp.tests.test_onlinehelp import I1
>>> from zope.app.onlinehelp.tests.test_onlinehelp import Dummy1, Dummy2
>>> from zope.app.onlinehelp import tests as ztapi
>>> from zope.component.interfaces import IFactory
>>> from zope.component.factory import Factory
Expand Down Expand Up @@ -141,7 +143,7 @@ def getTopicFor(obj, view=None):
view name and registered for that interface, still only the first
topic will be found.
>>> from zope.interface import Interface, implementer, alsoProvides
>>> from zope.interface import Interface, implementer
>>> class I3(Interface):
... pass
>>> @implementer(I3)
Expand Down Expand Up @@ -175,6 +177,7 @@ def getTopicFor(obj, view=None):
if topic.interface == interface and topic.view == view:
return topic


def _clear():
globalhelp.__init__(globalhelp.title, globalhelp.path)

Expand Down
2 changes: 1 addition & 1 deletion src/zope/app/onlinehelp/browser/__init__.py
Expand Up @@ -87,7 +87,7 @@ def getContextHelpTopic(self):
self.topic = getTopicFor(
getParent(help_context),
getName(help_context)
)
)
if self.topic is None:
# nothing found for view try context only
self.topic = getTopicFor(getParent(help_context))
Expand Down
15 changes: 8 additions & 7 deletions src/zope/app/onlinehelp/browser/tests.py
Expand Up @@ -19,13 +19,13 @@
import unittest

from zope.site.interfaces import IRootFolder
from zope.app.file import File
from zope.app.onlinehelp.tests.test_onlinehelp import testdir
from zope.app.onlinehelp import globalhelp
from zope.app.onlinehelp.testing import OnlineHelpLayer

from webtest import TestApp


class BrowserTestCase(unittest.TestCase):

layer = OnlineHelpLayer
Expand Down Expand Up @@ -57,23 +57,23 @@ def publish(self, path, basic=None, form=None, headers=None):
response = self._testapp.post(path, params=form,
extra_environ=env, headers=headers)
else:
response = self._testapp.get(path, extra_environ=env, headers=headers)
response = self._testapp.get(
path, extra_environ=env, headers=headers)

response.getBody = lambda: response.unicode_normal_body
response.getStatus = lambda: response.status_int
response.getHeader = lambda n: response.headers[n]
return response



class TestBrowser(BrowserTestCase):

def test_contexthelp(self):
path = os.path.join(testdir(), 'help.txt')
globalhelp.registerHelpTopic('help', 'Help', '', path, IRootFolder)
path = os.path.join(testdir(), 'help2.txt')
globalhelp.registerHelpTopic('help2', 'Help2', '', path, IRootFolder,
'contents.html')
'contents.html')

transaction.commit()

Expand Down Expand Up @@ -125,6 +125,7 @@ def test_contexthelp(self):

self.checkForBrokenLinks(body, path, basic='mgr:mgrpw')


class TestZPT(unittest.TestCase):

layer = OnlineHelpLayer
Expand Down Expand Up @@ -157,6 +158,7 @@ class Context(object):
zpt.topicContent = "the topic text"
zpt.renderTopic()


class TestContextHelpView(unittest.TestCase):

def test_idempotent(self):
Expand All @@ -168,6 +170,7 @@ def test_idempotent(self):

def test_without_view(self):
from zope.app.onlinehelp.browser import ContextHelpView

class Context(object):
@property
def context(self):
Expand All @@ -177,8 +180,6 @@ def context(self):
topic = view.getContextHelpTopic()
self.assertIs(context, topic)


def test_suite():
return unittest.defaultTestLoader.loadTestsFromName(__name__)

if __name__ == '__main__':
unittest.main()
7 changes: 4 additions & 3 deletions src/zope/app/onlinehelp/browser/tree.py
Expand Up @@ -23,6 +23,7 @@

from zope.app.onlinehelp.interfaces import IOnlineHelp


class OnlineHelpTopicTreeView(BrowserView):
"""Online help topic tree view."""

Expand All @@ -39,7 +40,7 @@ def getTopicTree(self):
Each time you get a level 0 means this is a subitem of the
Onlinehelp itself::
>>> info = [('id',{infoDict}),(),()]
>>> info = [('id',{infoDict}),(),()] # noqa: F821 undefined name
<ul class="tree" id="tree">
<li><a href="#">items</a>
Expand Down Expand Up @@ -117,7 +118,7 @@ def renderItemList(self, topic, intend):
def renderLink(self, topic):
"""Render a href element."""
title = translate(topic.title, context=self.request,
default=topic.title)
default=topic.title)
if topic.parentPath:
url = joinPath(topic.parentPath, topic.id)
else:
Expand All @@ -132,7 +133,7 @@ def isExpanded(self, topic):
try:
if getPath(self.context).startswith('/' + path):
return True
except:
except: # noqa: E722 do not use bare 'except'
# TODO: fix it, functional test doesn't like getPath? ri
pass
return False
76 changes: 39 additions & 37 deletions src/zope/app/onlinehelp/interfaces.py
Expand Up @@ -50,33 +50,34 @@ class IOnlineHelpTopic(IContainer):
The topic itself is stored in the IContainer implementation after add
the right parent topic of a child. This mechanism ensures that we don't
have to take care on the registration order.
The topic resources are stored in the :class:`zope.container.interfaces.IContainer` implementation of
the topic too.
The topic resources are stored in the
:class:`zope.container.interfaces.IContainer` implementation of the topic,
too.
"""

id = TextLine(
title = _(u"Id"),
description = _(u"The Id of this Help Topic"),
default = u"",
required = True)
title=_(u"Id"),
description=_(u"The Id of this Help Topic"),
default=u"",
required=True)

parentPath = TextLine(
title = _(u"Parent Path"),
description = _(u"The Path to the Parent of this Help Topic"),
default = u"",
required = False)
title=_(u"Parent Path"),
description=_(u"The Path to the Parent of this Help Topic"),
default=u"",
required=False)

title = TextLine(
title = _(u"Help Topic Title"),
description = _(u"The Title of a Help Topic"),
default = _(u"Help Topic"),
required = True)
title=_(u"Help Topic Title"),
description=_(u"The Title of a Help Topic"),
default=_(u"Help Topic"),
required=True)

path = TextLine(
title = _(u"Path to the Topic"),
description = _(u"The Path to the Definition of a Help Topic"),
default = u"./README.TXT",
required = True)
title=_(u"Path to the Topic"),
description=_(u"The Path to the Definition of a Help Topic"),
default=u"./README.TXT",
required=True)

interface = GlobalInterface(
title=_(u"Object Interface"),
Expand All @@ -85,11 +86,11 @@ class IOnlineHelpTopic(IContainer):
required=False)

view = TextLine(
title = _(u"View Name"),
description = _(u"The View Name for which this Help Topic"
" is registered"),
default = _(u""),
required = True)
title=_(u"View Name"),
description=_(u"The View Name for which this Help Topic"
" is registered"),
default=_(u""),
required=True)

def addResources(resources):
"""Add resources to this Help Topic.
Expand Down Expand Up @@ -120,8 +121,8 @@ class ISourceTextOnlineHelpTopic(IOnlineHelpTopic):
title=_(u"Source Type"),
description=_(u"Type of the source text, e.g. structured text"),
default=u"zope.source.rest",
required = True,
vocabulary = "SourceTypes")
required=True,
vocabulary="SourceTypes")


class IRESTOnlineHelpTopic(ISourceTextOnlineHelpTopic):
Expand Down Expand Up @@ -154,15 +155,16 @@ def registerHelpTopic(parent_path, id, title, doc_path,
:param title: Specifies title of the topic. This title will be used in
the tree as Identification.
:param doc_path: -- Specifies where the file that contains the topic content
is located.
:param doc_path: -- Specifies where the file that contains the topic
content is located.
:keyword interface: Name of the interface for which the help topic is being
registered. This can be optional, since not all topics must be bound
to a particular interface.
:keyword interface: Name of the interface for which the help topic is
being registered. This can be optional, since not all topics must
be bound to a particular interface.
:keyword view: This attribute specifies the name of the view for which this
topic is registered. Note that this attribute is also optional.
:keyword view: This attribute specifies the name of the view for which
this topic is registered. Note that this attribute is also
optional.
:keyword resources: Specifies a list of resources for the topic, for
example images that are included by the rendered topic content.
Expand All @@ -174,8 +176,8 @@ class IOnlineHelpResource(IFile, IFileContent):
"""A resource, which can be used in a help topic """

path = TextLine(
title = _(u"Path to the Resource"),
description = _(u"The Path to the Resource, assumed to be "
"in the same directory as the Help Topic"),
default = u"",
required = True)
title=_(u"Path to the Resource"),
description=_(u"The Path to the Resource, assumed to be "
"in the same directory as the Help Topic"),
default=u"",
required=True)
2 changes: 1 addition & 1 deletion src/zope/app/onlinehelp/metaconfigure.py
Expand Up @@ -25,7 +25,7 @@
class OnlineHelpTopicDirective(object):

def __init__(self, _context, id, title, parent="", doc_path=None,
for_=None, view=None, class_=None, resources=None):
for_=None, view=None, class_=None, resources=None):
self._context = _context
self.id = id
self.title = title
Expand Down
4 changes: 2 additions & 2 deletions src/zope/app/onlinehelp/metadirectives.py
Expand Up @@ -65,7 +65,7 @@ class IOnlineHelpTopicDirective(Interface):
description=u"""
The factory is the topic class used for initializeing the topic""",
required=False,
)
)

resources = Tokens(
title=u"A list of resources.",
Expand All @@ -76,4 +76,4 @@ class IOnlineHelpTopicDirective(Interface):
""",
value_type=TextLine(),
required=False
)
)

0 comments on commit c49ce5e

Please sign in to comment.