brain: fixes (zope.interface.implementer); + text: improvements

This commit is contained in:
Helmut Merz 2024-09-21 14:27:15 +02:00
parent 06682d2a5c
commit bd631677d6
5 changed files with 18 additions and 81 deletions

View file

@ -1,38 +1,18 @@
#
# Copyright (c) 2006 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.brain.neuron
"""
A simple basic implementation of Neuron and Synapsis.
$Id$
""" A simple basic implementation of Neuron and Synapsis.
"""
from zope.interface import implements
from zope.interface import implementer
from cybertools.brain.interfaces import INeuron, ISynapsis
from cybertools.brain.state import State, Transition
@implementer(ISynapsis)
class Synapsis(object):
""" A synapsis connects two neurons.
"""
implements(ISynapsis)
def __init__(self, sender, receiver):
self.sender = sender
sender.receivers.append(self)
@ -46,10 +26,9 @@ class Synapsis(object):
receiver.notify(session)
@implementer(INeuron)
class Neuron(object):
implements(INeuron)
def __init__(self):
self.senders = []
self.receivers = []

View file

@ -1,35 +1,15 @@
#
# Copyright (c) 2006 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.brain.session
"""
Transaction management.
$Id$
""" Transaction management.
"""
from zope.interface import implements
from zope.interface import implementer
from cybertools.brain.interfaces import ISession
implementer(ISession)
class Session(object):
implements(ISession)
def __init__(self):
self.states = {}

View file

@ -1,37 +1,17 @@
#
# Copyright (c) 2006 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.brain.state
"""
Base classes for state and state manipulations using a float-based state.
$Id$
""" Base classes for state and state manipulations using a float-based state.
"""
from zope.interface import implements
from zope.interface import implementer
from cybertools.brain.interfaces import IState, ITransition
@implementer(IState)
class State(object):
""" The state of a neuron.
"""
implements(IState)
def __init__(self, value=0.0):
self.value = value
@ -39,10 +19,9 @@ class State(object):
return '<State %0.1f>' % self.value
@implementer(ITransition)
class Transition(object):
implements(ITransition)
def __init__(self, synapsis, factor=1.0):
self.synapsis = synapsis
self.factor = factor

View file

@ -2,8 +2,6 @@
Text Transformations, e.g. for Full-text Indexing
=================================================
($Id$)
If a converter program needed is not available we want to put a warning
into Zope's server log; in order to be able to test this we register
a log handler for testing:

View file

@ -5,21 +5,22 @@ Tests for the 'cybertools.text' package.
"""
import sys
#sys.path = [p for p in sys.path if p != '']
sys.path = sys.path[2:]
print(sys.path)
sys.path = sys.path[2:] # avoid import cycle with bs4 when importing html
#print(sys.path)
import unittest, doctest
import warnings
from cybertools.text import pdf
from cybertools.text.html import htmlToText
warnings.filterwarnings('ignore', category=ResourceWarning)
class Test(unittest.TestCase):
"Basic tests for the text package."
def testBasicStuff(self):
warnings.filterwarnings('ignore', category=ResourceWarning)
warnings.filterwarnings('ignore', category=DeprecationWarning)
pass