From c9220d834df9315319afef69d528dd900aad3333 Mon Sep 17 00:00:00 2001 From: Helmut Merz Date: Sun, 22 Sep 2024 14:46:28 +0200 Subject: [PATCH] linK: Python3 fixes --- cybertools/link/README.txt | 2 +- cybertools/link/base.py | 31 +++++-------------------------- cybertools/link/tests.py | 8 ++++---- 3 files changed, 10 insertions(+), 31 deletions(-) diff --git a/cybertools/link/README.txt b/cybertools/link/README.txt index d6f7c13..64a3470 100644 --- a/cybertools/link/README.txt +++ b/cybertools/link/README.txt @@ -43,7 +43,7 @@ of its attributes. >>> (l01.identifier, l01.source, l01.target, l01.name, l01.linkType, l01.state, ... l01.relevance, l01.order) - (1, 0, 1, 'p2', u'link', u'valid', 1.0, 0) + (1, 0, 1, 'p2', 'link', 'valid', 1.0, 0) Query for links --------------- diff --git a/cybertools/link/base.py b/cybertools/link/base.py index e3085f7..755159d 100644 --- a/cybertools/link/base.py +++ b/cybertools/link/base.py @@ -1,25 +1,6 @@ -# -# 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 -# +# cybertools.link.base -""" -A simple generic, general-purpose link management framework. - -$Id$ +""" A simple generic, general-purpose link management framework. """ from BTrees.IFBTree import intersection, union @@ -28,18 +9,17 @@ from persistent import Persistent from zope import component from zope.component import adapts from zope.index.field import FieldIndex -from zope.interface import implements +from zope.interface import implementer from zope.intid.interfaces import IIntIds from cybertools.link.interfaces import ILinkManager, ILink +@implementer(ILinkManager) class LinkManager(Persistent): """ A manager (storage, registry) for link objects. """ - implements(ILinkManager) - uid = int # initialization @@ -127,12 +107,11 @@ class LinkManager(Persistent): return component.getUtility(IIntIds).getObject(uid) +@implementer(ILink) class Link(Persistent): """ A basic link implementation. """ - implements(ILink) - defaults = dict(target=None, linkType=u'link', state=u'valid', diff --git a/cybertools/link/tests.py b/cybertools/link/tests.py index 2aa8337..7569fc1 100755 --- a/cybertools/link/tests.py +++ b/cybertools/link/tests.py @@ -1,15 +1,15 @@ +# cybertools.link.tests import unittest, doctest from zope.interface.verify import verifyClass -from zope.interface import implements +from zope.interface import implementer from zope.intid.interfaces import IIntIds +@implementer(IIntIds) class IntIdsStub(object): """A testing stub (mock utility) for IntIds.""" - implements(IIntIds) - def __init__(self): self.objs = [] @@ -29,7 +29,7 @@ class IntIdsStub(object): self.objs[id] = None def __iter__(self): - return iter(xrange(len(self.objs))) + return iter(range(len(self.objs))) class TestLink(unittest.TestCase):