From 14ea59a3079ac0e2b29b5192d140aafa4b2c4205 Mon Sep 17 00:00:00 2001 From: Helmut Merz Date: Wed, 23 Oct 2024 10:32:58 +0200 Subject: [PATCH] more Python3 fixes: remove basestring, unicode --- loops/browser/form.py | 2 +- loops/expert/browser/report.py | 2 +- loops/expert/field.py | 23 +++-------------------- loops/knowledge/survey/browser.py | 2 +- loops/organize/tracking/browser.py | 25 ++++--------------------- loops/server/psu.py | 2 +- loops/table.py | 2 +- 7 files changed, 12 insertions(+), 46 deletions(-) diff --git a/loops/browser/form.py b/loops/browser/form.py index eacc61d..25b3678 100755 --- a/loops/browser/form.py +++ b/loops/browser/form.py @@ -166,7 +166,7 @@ class ObjectForm(NodeView): if field: fi = field.getFieldInstance(self.instance) input = form[k] - if isinstance(input, basestring): + if isinstance(input, str): input = unquote_plus(input) data[k] = fi.marshall(fi.unmarshall(input)) #data[k] = toUnicode(form[k]) diff --git a/loops/expert/browser/report.py b/loops/expert/browser/report.py index 9ce1992..9a1e678 100755 --- a/loops/expert/browser/report.py +++ b/loops/expert/browser/report.py @@ -100,7 +100,7 @@ class ResultsView(NodeView): def parseLimitsParam(self, value): if not value: return None - if isinstance(value, basestring): + if isinstance(value, str): limits = value.split(',') else: limits = value diff --git a/loops/expert/field.py b/loops/expert/field.py index a37a53a..17d9492 100644 --- a/loops/expert/field.py +++ b/loops/expert/field.py @@ -1,23 +1,6 @@ -# -# 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 -# +# loops.expert.field -""" -Field definitions for reports. +""" Field definitions for reports. """ from zope.app.form.browser.interfaces import ITerms @@ -210,7 +193,7 @@ class VocabularyField(Field): if request is None: request = row.parent.context.view.request voc = self.vocabulary - if isinstance(voc, basestring): + if isinstance(voc, str): terms = self.getVocabularyTerms(voc, context, request) if terms is not None: return terms diff --git a/loops/knowledge/survey/browser.py b/loops/knowledge/survey/browser.py index 6dd3cd9..63f075f 100644 --- a/loops/knowledge/survey/browser.py +++ b/loops/knowledge/survey/browser.py @@ -290,7 +290,7 @@ class SurveyView(InstitutionMixin, ConceptView): result['average'] = int(round(average)) result['stddev'] = int(round(stddev)) texts = [r.texts.get(question) for r in self.teamData] - result['texts'] = '
'.join([unicode(t) for t in texts if t]) + result['texts'] = '
'.join([t for t in texts if t]) return result def prefsResults(self, respManager, form, action): diff --git a/loops/organize/tracking/browser.py b/loops/organize/tracking/browser.py index 391cd90..235b3c9 100644 --- a/loops/organize/tracking/browser.py +++ b/loops/organize/tracking/browser.py @@ -1,23 +1,6 @@ -# -# Copyright (c) 2014 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 -# +# loops.organize.tracking.browser -""" -View classes for tracks. +""" View classes for tracks. """ from zope import component @@ -82,7 +65,7 @@ class BaseTrackView(TrackView): @Lazy def userTitle(self): - if isinstance(self.user, basestring): + if isinstance(self.user, str): uid = self.user try: return self.authentication.getPrincipal(uid).title or uid @@ -93,7 +76,7 @@ class BaseTrackView(TrackView): @Lazy def userUrl(self): user = self.user - if user is not None and not isinstance(user, basestring): + if user is not None and not isinstance(user, str): return '%s/@@introspector.html' % absoluteURL(user, self.request) def getMetadataTarget(self, key): diff --git a/loops/server/psu.py b/loops/server/psu.py index 89aa566..da3ab88 100644 --- a/loops/server/psu.py +++ b/loops/server/psu.py @@ -141,7 +141,7 @@ def move(source, target, name): commit() def get(container, obj): - if isinstance(obj, basestring): + if isinstance(obj, str): name = obj obj = container.get(name) if obj is None: diff --git a/loops/table.py b/loops/table.py index dfd1e92..c888c6a 100644 --- a/loops/table.py +++ b/loops/table.py @@ -131,7 +131,7 @@ def getRowValue(k, v): return v[0] def getRowValueWithKey(k, v): - return u' '.join((unicode(k), v[0])) + return ' '.join((k, v[0])) @implementer(IIterableSource)