From 52e3fc72c69d350508c45e1967fadf37d35862eb Mon Sep 17 00:00:00 2001 From: Helmut Merz Date: Wed, 25 Sep 2024 10:57:30 +0200 Subject: [PATCH] more Python3 fixes in composer, knowledge --- cybertools/composer/report/base.py | 38 +++++--------------- cybertools/composer/report/field.py | 26 +++----------- cybertools/knowledge/survey/questionnaire.py | 38 +++++--------------- 3 files changed, 20 insertions(+), 82 deletions(-) diff --git a/cybertools/composer/report/base.py b/cybertools/composer/report/base.py index b3b34d3..e405f1a 100644 --- a/cybertools/composer/report/base.py +++ b/cybertools/composer/report/base.py @@ -1,27 +1,10 @@ -# -# 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.composer.report.base -""" -Basic classes for report management. +""" Basic classes for report management. """ import operator as standard_operators -from zope.interface import implements +from zope.interface import implementer from cybertools.composer.base import Component, Element, Compound from cybertools.composer.base import Template @@ -33,10 +16,9 @@ from cybertools.util.jeep import Jeep from cybertools.util.randomname import generateName +@implementer(IReportManager) class ReportManager(object): - implements(IReportManager) - reports = manager = None reportsFactory = dict @@ -63,10 +45,9 @@ class ReportManager(object): return self.reports.get(id) +@implementer(IReport) class Report(Template): - implements(IReport) - name = identifier = u'' #title = description = u'' type = 'generic' @@ -162,18 +143,16 @@ class Report(Template): return [f for f in self.fields if f.name == field.output] +@implementer(IQueryCriteria) class BaseQueryCriteria(Component): - implements(IQueryCriteria) - def check(self, obj): return True +@implementer(ILeafQueryCriteria) class LeafQueryCriteria(BaseQueryCriteria, Element): - implements(ILeafQueryCriteria) - def __init__(self, name, operator, comparisonValue, field): self.name = name self.operator = operator @@ -235,10 +214,9 @@ operators = {'any': checkAny, 'not_any': checkNotAny, 'in': checkIn, 'only': checkOnly} +@implementer(ICompoundQueryCriteria) class CompoundQueryCriteria(BaseQueryCriteria, Compound): - implements(ICompoundQueryCriteria) - logicalOperator = 'and' def __init__(self, parts): diff --git a/cybertools/composer/report/field.py b/cybertools/composer/report/field.py index 9c5d441..cd16434 100644 --- a/cybertools/composer/report/field.py +++ b/cybertools/composer/report/field.py @@ -1,28 +1,11 @@ -# -# Copyright (c) 2016 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.composer.report.field -""" -Implementation of report field definitions. +""" Implementation of report field definitions. """ from datetime import datetime from time import strptime, strftime -from zope.interface import implements +from zope.interface import implementer from zope.cachedescriptors.property import Lazy from zope.component import adapts from zope import component @@ -63,10 +46,9 @@ class TableCellStyle(Style): } +@implementer(IField) class Field(Component): - implements(IField) - fieldType = 'text' vocabulary = None default = defaultComparisonValue = None diff --git a/cybertools/knowledge/survey/questionnaire.py b/cybertools/knowledge/survey/questionnaire.py index 6fb6146..6e4b0d2 100644 --- a/cybertools/knowledge/survey/questionnaire.py +++ b/cybertools/knowledge/survey/questionnaire.py @@ -1,35 +1,17 @@ -# -# Copyright (c) 2015 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.knowledge.survey.questionnaire -""" -Questionnaires, questions and other stuff needed for surveys. +""" Questionnaires, questions and other stuff needed for surveys. """ -from zope.interface import implements +from zope.interface import implementer from cybertools.knowledge.survey.interfaces import IQuestionnaire from cybertools.knowledge.survey.interfaces import IQuestionGroup, IQuestion from cybertools.knowledge.survey.interfaces import IFeedbackItem, IResponse +@implementer(IQuestionnaire) class Questionnaire(object): - implements(IQuestionnaire) - def __init__(self): self.questionGroups = [] self.questions = [] @@ -40,20 +22,18 @@ class Questionnaire(object): return self.questionGroups +@implementer(IQuestionGroup) class QuestionGroup(object): - implements(IQuestionGroup) - def __init__(self, questionnaire): self.questionnaire = questionnaire self.questions = [] self.feedbackItems = [] +@implementer(IQuestion) class Question(object): - implements(IQuestion) - _answerRange = None def __init__(self, questionnaire, text=u''): @@ -65,18 +45,16 @@ class Question(object): self.answerRange = None +@implementer(IFeedbackItem) class FeedbackItem(object): - implements(IFeedbackItem) - def __init__(self, text=u''): self.text = text +@implementer(IResponse) class Response(object): - implements(IResponse) - def __init__(self, questionnaire, party): self.questionnaire = questionnaire self.party = party