more Python3 fixes in composer, knowledge

This commit is contained in:
Helmut Merz 2024-09-25 10:57:30 +02:00
parent db31a73bc9
commit 52e3fc72c6
3 changed files with 20 additions and 82 deletions

View file

@ -1,27 +1,10 @@
# # cybertools.composer.report.base
# 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
#
""" """ Basic classes for report management.
Basic classes for report management.
""" """
import operator as standard_operators 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 Component, Element, Compound
from cybertools.composer.base import Template from cybertools.composer.base import Template
@ -33,10 +16,9 @@ from cybertools.util.jeep import Jeep
from cybertools.util.randomname import generateName from cybertools.util.randomname import generateName
@implementer(IReportManager)
class ReportManager(object): class ReportManager(object):
implements(IReportManager)
reports = manager = None reports = manager = None
reportsFactory = dict reportsFactory = dict
@ -63,10 +45,9 @@ class ReportManager(object):
return self.reports.get(id) return self.reports.get(id)
@implementer(IReport)
class Report(Template): class Report(Template):
implements(IReport)
name = identifier = u'' name = identifier = u''
#title = description = u'' #title = description = u''
type = 'generic' type = 'generic'
@ -162,18 +143,16 @@ class Report(Template):
return [f for f in self.fields if f.name == field.output] return [f for f in self.fields if f.name == field.output]
@implementer(IQueryCriteria)
class BaseQueryCriteria(Component): class BaseQueryCriteria(Component):
implements(IQueryCriteria)
def check(self, obj): def check(self, obj):
return True return True
@implementer(ILeafQueryCriteria)
class LeafQueryCriteria(BaseQueryCriteria, Element): class LeafQueryCriteria(BaseQueryCriteria, Element):
implements(ILeafQueryCriteria)
def __init__(self, name, operator, comparisonValue, field): def __init__(self, name, operator, comparisonValue, field):
self.name = name self.name = name
self.operator = operator self.operator = operator
@ -235,10 +214,9 @@ operators = {'any': checkAny, 'not_any': checkNotAny,
'in': checkIn, 'only': checkOnly} 'in': checkIn, 'only': checkOnly}
@implementer(ICompoundQueryCriteria)
class CompoundQueryCriteria(BaseQueryCriteria, Compound): class CompoundQueryCriteria(BaseQueryCriteria, Compound):
implements(ICompoundQueryCriteria)
logicalOperator = 'and' logicalOperator = 'and'
def __init__(self, parts): def __init__(self, parts):

View file

@ -1,28 +1,11 @@
# # cybertools.composer.report.field
# 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
#
""" """ Implementation of report field definitions.
Implementation of report field definitions.
""" """
from datetime import datetime from datetime import datetime
from time import strptime, strftime from time import strptime, strftime
from zope.interface import implements from zope.interface import implementer
from zope.cachedescriptors.property import Lazy from zope.cachedescriptors.property import Lazy
from zope.component import adapts from zope.component import adapts
from zope import component from zope import component
@ -63,10 +46,9 @@ class TableCellStyle(Style):
} }
@implementer(IField)
class Field(Component): class Field(Component):
implements(IField)
fieldType = 'text' fieldType = 'text'
vocabulary = None vocabulary = None
default = defaultComparisonValue = None default = defaultComparisonValue = None

View file

@ -1,35 +1,17 @@
# # cybertools.knowledge.survey.questionnaire
# 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
#
""" """ 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 IQuestionnaire
from cybertools.knowledge.survey.interfaces import IQuestionGroup, IQuestion from cybertools.knowledge.survey.interfaces import IQuestionGroup, IQuestion
from cybertools.knowledge.survey.interfaces import IFeedbackItem, IResponse from cybertools.knowledge.survey.interfaces import IFeedbackItem, IResponse
@implementer(IQuestionnaire)
class Questionnaire(object): class Questionnaire(object):
implements(IQuestionnaire)
def __init__(self): def __init__(self):
self.questionGroups = [] self.questionGroups = []
self.questions = [] self.questions = []
@ -40,20 +22,18 @@ class Questionnaire(object):
return self.questionGroups return self.questionGroups
@implementer(IQuestionGroup)
class QuestionGroup(object): class QuestionGroup(object):
implements(IQuestionGroup)
def __init__(self, questionnaire): def __init__(self, questionnaire):
self.questionnaire = questionnaire self.questionnaire = questionnaire
self.questions = [] self.questions = []
self.feedbackItems = [] self.feedbackItems = []
@implementer(IQuestion)
class Question(object): class Question(object):
implements(IQuestion)
_answerRange = None _answerRange = None
def __init__(self, questionnaire, text=u''): def __init__(self, questionnaire, text=u''):
@ -65,18 +45,16 @@ class Question(object):
self.answerRange = None self.answerRange = None
@implementer(IFeedbackItem)
class FeedbackItem(object): class FeedbackItem(object):
implements(IFeedbackItem)
def __init__(self, text=u''): def __init__(self, text=u''):
self.text = text self.text = text
@implementer(IResponse)
class Response(object): class Response(object):
implements(IResponse)
def __init__(self, questionnaire, party): def __init__(self, questionnaire, party):
self.questionnaire = questionnaire self.questionnaire = questionnaire
self.party = party self.party = party