more Python3 fixes: remove basestring, unicode

This commit is contained in:
Helmut Merz 2024-10-23 10:32:58 +02:00
parent 8d7cda5ec0
commit 14ea59a307
7 changed files with 12 additions and 46 deletions

View file

@ -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])

View file

@ -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

View file

@ -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

View file

@ -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'] = '<br />'.join([unicode(t) for t in texts if t])
result['texts'] = '<br />'.join([t for t in texts if t])
return result
def prefsResults(self, respManager, form, action):

View file

@ -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):

View file

@ -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:

View file

@ -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)