some more Python3 fixes...

This commit is contained in:
Helmut Merz 2024-09-23 15:35:14 +02:00
parent b8eba239ed
commit 9fbd97386e
14 changed files with 57 additions and 266 deletions

View file

@ -2,8 +2,6 @@
Yet Another WikiWiki Framework Yet Another WikiWiki Framework
============================== ==============================
($Id$)
>>> from zope import component >>> from zope import component
>>> from zope.publisher.browser import TestRequest >>> from zope.publisher.browser import TestRequest
@ -33,7 +31,7 @@ We format the content of the start page using the restructured text format.
The parser for restructured text and a corresponding HTML writer are the The parser for restructured text and a corresponding HTML writer are the
default plugins used, so we can already render the page as HTML. default plugins used, so we can already render the page as HTML.
>>> print startPage.render(TestRequest()) >>> print(startPage.render(TestRequest()))
<p><strong>Welcome to the Demo Wiki</strong></p> <p><strong>Welcome to the Demo Wiki</strong></p>
Links to existing pages Links to existing pages
@ -50,7 +48,7 @@ We now create another page that contains a link to the start page.
... `Back to the Start Page <start_page>`_ ... `Back to the Start Page <start_page>`_
... ''' ... '''
>>> print aboutPage.render(TestRequest()) >>> print(aboutPage.render(TestRequest()))
<p><strong>Information about the Demo Wiki</strong></p> <p><strong>Information about the Demo Wiki</strong></p>
<p>This is the cybertools demo wiki.</p> <p>This is the cybertools demo wiki.</p>
<p><a class="reference" <p><a class="reference"
@ -77,7 +75,7 @@ should lead to a view that will create the page.
>>> aboutPage.text += ''' >>> aboutPage.text += '''
... `More... <more>`_ ... `More... <more>`_
... ''' ... '''
>>> print aboutPage.render(TestRequest()) >>> print(aboutPage.render(TestRequest()))
<p><strong>Information about the Demo Wiki</strong></p> <p><strong>Information about the Demo Wiki</strong></p>
<p>This is the cybertools demo wiki.</p> <p>This is the cybertools demo wiki.</p>
<p><a class="reference" <p><a class="reference"
@ -91,7 +89,7 @@ rendering operations.
>>> len(links) >>> len(links)
2 2
>>> print aboutPage.render(TestRequest()) >>> print(aboutPage.render(TestRequest()))
<p>... <p>...
<p><a class="reference create" <p><a class="reference create"
href="http://127.0.0.1/demo_wiki/&#64;&#64;create.html?name=more">?More...</a></p> href="http://127.0.0.1/demo_wiki/&#64;&#64;create.html?name=more">?More...</a></p>
@ -110,7 +108,7 @@ Links with fragments (anchor references) and parameters
... - `More content <more#content?language=en>`_ ... - `More content <more#content?language=en>`_
... ''' ... '''
>>> print referencePage.render(TestRequest()) >>> print(referencePage.render(TestRequest()))
<h1 class="title">References</h1> <h1 class="title">References</h1>
<ul class="simple"> <ul class="simple">
<li><a class="reference" <li><a class="reference"
@ -132,7 +130,7 @@ External links
An absolute URL given as link target will not be changed in the process. An absolute URL given as link target will not be changed in the process.
>>> print linksPage.render(TestRequest()) >>> print(linksPage.render(TestRequest()))
<p><strong>A collection of interesting links</strong></p> <p><strong>A collection of interesting links</strong></p>
<ul class="simple"> <ul class="simple">
<li><a class="reference" <li><a class="reference"
@ -148,7 +146,7 @@ Nevertheless the links are registered in the link manager.
When we render external links repeatedly no new link objects will be When we render external links repeatedly no new link objects will be
created. created.
>>> print linksPage.render(TestRequest()) >>> print(linksPage.render(TestRequest()))
<p><strong>A collection of interesting links</strong></p> <p><strong>A collection of interesting links</strong></p>
<ul class="simple"> <ul class="simple">
<li><a class="reference" <li><a class="reference"
@ -187,7 +185,7 @@ Embed media objects (images) in Wiki text
... `Back to the Start Page <start_page>`_ ... `Back to the Start Page <start_page>`_
... ''' ... '''
>>> print imagePage1.render(TestRequest()) >>> print(imagePage1.render(TestRequest()))
<p><strong>A page with an image</strong></p> <p><strong>A page with an image</strong></p>
<img src="http://127.0.0.1/demo_wiki/.media/media01.jpg" /> <img src="http://127.0.0.1/demo_wiki/.media/media01.jpg" />
<p><a class="reference" <p><a class="reference"
@ -205,7 +203,7 @@ Link to media objects (files) in Wiki text
... `Back to the Start Page <start_page>`_ ... `Back to the Start Page <start_page>`_
... ''' ... '''
>>> print imagePage2.render(TestRequest()) >>> print(imagePage2.render(TestRequest()))
<p><strong>A page with a link to an image</strong></p> <p><strong>A page with a link to an image</strong></p>
<p><a class="reference" <p><a class="reference"
href="http://127.0.0.1/demo_wiki/.media/media01.jpg">Media Object #1</a></p> href="http://127.0.0.1/demo_wiki/.media/media01.jpg">Media Object #1</a></p>

View file

@ -1,36 +1,16 @@
# # cybertools.wiki.base.config
# Copyright (c) 2009 Helmut Merz helmutm@cy55.de
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
""" """ Basic Configuration implementations.
Basic Configuration implementations.
$Id$
""" """
from zope.interface import implements from zope.interface import implementer
from cybertools.wiki.interfaces import IWikiConfigInfo, IWikiConfiguration from cybertools.wiki.interfaces import IWikiConfigInfo, IWikiConfiguration
@implementer(IWikiConfigInfo)
class WikiConfigInfo(dict): class WikiConfigInfo(dict):
implements(IWikiConfigInfo)
def set(self, functionality, value): def set(self, functionality, value):
self[functionality] = value self[functionality] = value
@ -52,12 +32,11 @@ class BaseConfigurator(object):
return self.context._configInfo return self.context._configInfo
@implementer(IWikiConfiguration)
class BaseConfiguration(object): class BaseConfiguration(object):
""" The base class for all wiki configuration implementations. """ The base class for all wiki configuration implementations.
""" """
implements(IWikiConfiguration)
configurator = BaseConfigurator configurator = BaseConfigurator
_configInfo = None _configInfo = None

View file

@ -1,40 +1,20 @@
# # cybertools.wiki.base.link
# Copyright (c) 2010 Helmut Merz helmutm@cy55.de
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
""" """ Basic (sample) implementations for links and link management.
Basic (sample) implementations for links and link management.
$Id$
""" """
from docutils.nodes import Text from docutils.nodes import Text
from zope.interface import implements from zope.interface import implementer
from zope.traversing.browser import absoluteURL from zope.traversing.browser import absoluteURL
from cybertools.link.interfaces import ILink, ILinkManager from cybertools.link.interfaces import ILink, ILinkManager
from cybertools.wiki.interfaces import ILinkProcessor from cybertools.wiki.interfaces import ILinkProcessor
@implementer(ILinkProcessor)
class LinkProcessor(object): class LinkProcessor(object):
""" Abstract base class. """ """ Abstract base class. """
implements(ILinkProcessor)
source = request = None source = request = None
targetName = '' targetName = ''

View file

@ -1,37 +1,18 @@
# # cybertools.wiki.base.media
# Copyright (c) 2010 Helmut Merz helmutm@cy55.de
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
""" """ Basic (sample) implementation for a wiki media manager and media objects.
Basic (sample) implementation for a wiki media manager and media objects.
$Id$
""" """
from zope.component import adapts from zope.component import adapts
from zope.interface import implements from zope.interface import implementer
from zope.traversing.browser import absoluteURL from zope.traversing.browser import absoluteURL
from cybertools.wiki.interfaces import IWiki, IMediaManager, IMediaObject from cybertools.wiki.interfaces import IWiki, IMediaManager, IMediaObject
@implementer(IMediaManager)
class WikiMediaManager(object): class WikiMediaManager(object):
""" A Wiki adapter for providing media manager functionality. """ """ A Wiki adapter for providing media manager functionality. """
implements(IMediaManager)
adapts(IWiki) adapts(IWiki)
name = '.media' name = '.media'
@ -62,11 +43,10 @@ class WikiMediaManager(object):
return self.objects.values() return self.objects.values()
@implementer(IMediaObject)
class MediaObject(object): class MediaObject(object):
""" A basic (maybe persistent) media object. """ """ A basic (maybe persistent) media object. """
implements(IMediaObject)
data = None data = None
def __init__(self, name, title=None, parent=None): def __init__(self, name, title=None, parent=None):

View file

@ -1,29 +1,10 @@
# # cybertools.wiki.base.wiki
# Copyright (c) 2010 Helmut Merz helmutm@cy55.de
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
""" """ A Wiki manager managing wikis and wiki-related objects, esp plugins.
A Wiki manager managing wikis and wiki-related objects, esp plugins.
$Id$
""" """
from zope import component from zope import component
from zope.interface import implements from zope.interface import implementer
from zope.intid.interfaces import IIntIds from zope.intid.interfaces import IIntIds
from zope.traversing.browser import absoluteURL from zope.traversing.browser import absoluteURL
@ -35,10 +16,9 @@ from cybertools.wiki.interfaces import IParser, IWriter
from cybertools.wiki.base.config import BaseConfiguration from cybertools.wiki.base.config import BaseConfiguration
@implementer(IWikiManager)
class WikiManager(BaseConfiguration): class WikiManager(BaseConfiguration):
implements(IWikiManager)
def __init__(self): def __init__(self):
self.setup() self.setup()
@ -91,7 +71,7 @@ class WikiManager(BaseConfiguration):
return obj return obj
def resolveUid(self, uid): def resolveUid(self, uid):
if isinstance(uid, basestring): if isinstance(uid, str):
if ':' in uid: if ':' in uid:
protocol, address = uid.split(':', 1) protocol, address = uid.split(':', 1)
if protocol.lower() in protocols: if protocol.lower() in protocols:
@ -106,10 +86,9 @@ class WikiManager(BaseConfiguration):
return component.getUtility(IWikiConfiguration) return component.getUtility(IWikiConfiguration)
@implementer(IWiki)
class Wiki(BaseConfiguration): class Wiki(BaseConfiguration):
implements(IWiki)
manager = None manager = None
def __init__(self, name, title=None): def __init__(self, name, title=None):
@ -164,10 +143,9 @@ class Wiki(BaseConfiguration):
return self.getManager() return self.getManager()
@implementer(IWikiPage)
class WikiPage(BaseConfiguration): class WikiPage(BaseConfiguration):
implements(IWikiPage)
wiki = None wiki = None
text = u'' text = u''

View file

@ -1,28 +1,9 @@
# # cybertools.wiki.common
# Copyright (c) 2009 Helmut Merz helmutm@cy55.de
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
""" """ Common basic generic stuff.
Common basic generic stuff.
$Id$
""" """
from zope.interface import implements from zope.interface import implementer
from cybertools.wiki.interfaces import IWebResource from cybertools.wiki.interfaces import IWebResource
@ -31,10 +12,9 @@ protocols = set(['dav', 'file', 'ftp', 'http', 'https', 'javascript',
'mailto', 'sftp', 'smb']) 'mailto', 'sftp', 'smb'])
@implementer(IWebResource)
class ExternalPage(object): class ExternalPage(object):
implements(IWebResource)
def __init__(self, uid): def __init__(self, uid):
self.uid = uid self.uid = uid

View file

@ -1,32 +1,13 @@
# # cybertools.wiki.dcu.html
# Copyright (c) 2010 Helmut Merz helmutm@cy55.de
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
""" """ A writer implementation based on the docutils HTML writer.
A writer implementation based on the docutils HTML writer.
$Id$
""" """
from docutils.core import publish_from_doctree from docutils.core import publish_from_doctree
from docutils import nodes from docutils import nodes
from docutils.writers.html4css1 import HTMLTranslator, Writer as HTMLWriter from docutils.writers.html4css1 import HTMLTranslator, Writer as HTMLWriter
from zope import component from zope import component
from zope.interface import implements from zope.interface import implementer
from cybertools.wiki.interfaces import INodeProcessor, IWriter from cybertools.wiki.interfaces import INodeProcessor, IWriter
@ -39,10 +20,9 @@ class HTMLWriter(HTMLWriter):
return template % subs return template % subs
@implementer(IWriter)
class Writer(object): class Writer(object):
implements(IWriter)
def __init__(self): def __init__(self):
self.writer = HTMLWriter() self.writer = HTMLWriter()
self.writer.translator_class = BodyTranslator self.writer.translator_class = BodyTranslator

View file

@ -1,32 +1,12 @@
# # cybertools.wiki.dcu.process
# Copyright (c) 2009 Helmut Merz helmutm@cy55.de
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
""" """ Node processor implementations for docutils nodes.
Node processor implementations for docutils nodes.
$Id: process.py 3153 2009-01-17 16:51:09Z helmutm $
""" """
from docutils.nodes import Text from docutils.nodes import Text
from zope import component from zope import component
from zope.cachedescriptors.property import Lazy from zope.cachedescriptors.property import Lazy
from zope.component import adapts from zope.component import adapts
from zope.interface import implements
from cybertools.wiki.base.link import LinkProcessor from cybertools.wiki.base.link import LinkProcessor
from cybertools.wiki.dcu.html import HTMLImageNode, HTMLReferenceNode from cybertools.wiki.dcu.html import HTMLImageNode, HTMLReferenceNode

View file

@ -1,37 +1,17 @@
# # cybertools.wiki.dcu.rstx
# Copyright (c) 2009 Helmut Merz helmutm@cy55.de
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
""" """ A parser implementation based on the docutils restructured text parser.
A parser implementation based on the docutils restructured text parser.
$Id$
""" """
from docutils.core import publish_doctree from docutils.core import publish_doctree
from zope.interface import implements from zope.interface import implementer
from cybertools.wiki.interfaces import IParser from cybertools.wiki.interfaces import IParser
@implementer(IParser)
class Parser(object): class Parser(object):
implements(IParser)
def parse(self, text, context=None, request=None): def parse(self, text, context=None, request=None):
tree = publish_doctree(text) tree = publish_doctree(text)
tree.context = context tree.context = context

View file

@ -1,25 +1,6 @@
# # cybertools.wiki.generic.adapter
# Copyright (c) 2011 Helmut Merz helmutm@cy55.de
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
""" """ Wiki implementation = adapters for Zope2 content objects.
Wiki implementation = adapters for Zope2 content objects.
$Id$
""" """
try: try:
@ -32,7 +13,7 @@ from persistent.mapping import PersistentMapping
from zope.cachedescriptors.property import Lazy from zope.cachedescriptors.property import Lazy
from zope import component from zope import component
from zope.component import adapts from zope.component import adapts
from zope.interface import implements from zope.interface import implementer
from zope.intid import IntIds from zope.intid import IntIds
from zope.intid.interfaces import IIntIds from zope.intid.interfaces import IIntIds
@ -45,10 +26,9 @@ from cybertools.wiki.base.wiki import WikiPage as BaseWikiPage
from cybertools.wiki.interfaces import ILinkManager, IWikiConfigInfo from cybertools.wiki.interfaces import ILinkManager, IWikiConfigInfo
@implementer(IWikiConfigInfo)
class PersistentConfigInfo(PersistentMapping): class PersistentConfigInfo(PersistentMapping):
implements(IWikiConfigInfo)
def set(self, functionality, value): def set(self, functionality, value):
self[functionality] = value self[functionality] = value

View file

@ -2,8 +2,6 @@
Standard Wiki Pre-processors Standard Wiki Pre-processors
============================ ============================
($Id$)
MediaWiki Formatting MediaWiki Formatting
==================== ====================
@ -24,6 +22,6 @@ Embedding of Images
>>> src = '''[[image:media01.jpg]]''' >>> src = '''[[image:media01.jpg]]'''
>>> print preprocess(src) >>> print(preprocess(src))
.. image:: media01.jpg .. image:: media01.jpg

View file

@ -1,14 +1,11 @@
#! /usr/bin/python # cybertools.wiki.tests
""" """ Tests for the 'cybertools.wiki' package.
Tests for the 'cybertools.wiki' package.
$Id$
""" """
import unittest, doctest import unittest, doctest
from zope import component from zope import component
from zope.interface import implements from zope.interface import implementer
from zope.intid.interfaces import IIntIds from zope.intid.interfaces import IIntIds
from zope.publisher.interfaces.browser import IBrowserRequest from zope.publisher.interfaces.browser import IBrowserRequest
from zope.traversing.browser.interfaces import IAbsoluteURL from zope.traversing.browser.interfaces import IAbsoluteURL
@ -25,10 +22,9 @@ from cybertools.wiki.interfaces import IWiki, IWikiPage, IMediaObject
#from cybertools.wiki.tracking import link #from cybertools.wiki.tracking import link
@implementer(IAbsoluteURL)
class WikiURL(object): class WikiURL(object):
implements(IAbsoluteURL)
def __init__(self, context, request): def __init__(self, context, request):
self.context = context self.context = context
self.request = request self.request = request

View file

@ -1,25 +1,6 @@
# # cybertools.xedit.browser
# Copyright (c) 2011 Helmut Merz helmutm@cy55.de
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
""" """ (View) class(es) for the external editor functionality.
(View) class(es) for the external editor functionality.
$Id$
""" """
from zope.app.pagetemplate import ViewPageTemplateFile from zope.app.pagetemplate import ViewPageTemplateFile
@ -49,7 +30,7 @@ class ExternalEditorView(object):
r.append('title:' + fromUnicode(context.title)) r.append('title:' + fromUnicode(context.title))
auth = self.request.get('_auth') auth = self.request.get('_auth')
if auth: if auth:
print 'ExternalEditorView: auth = ', auth print('ExternalEditorView: auth = ', auth)
if auth.endswith('\n'): if auth.endswith('\n'):
auth = auth[:-1] auth = auth[:-1]
r.append('auth:' + auth) r.append('auth:' + auth)

View file

@ -14,6 +14,7 @@ authors = [{name = "Helmut Merz", email = "helmutm@cy55.de"}]
dependencies = [ dependencies = [
"bs4", "bs4",
"BTrees", "BTrees",
"docutils",
"lxml", "lxml",
"persistent", "persistent",
"pillow", "pillow",