Commit bb7d1071 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

py2/py3: stop using deprecated string functions, that are removed in python 3.

parent b3039664
......@@ -13,8 +13,8 @@ for item in item_list:
item_value = item[int(not is_right_display)]
# Hash key from item_value
item_split = string.split(item_value, '/')
item_key = string.join(item_split[:split_depth] , '/' )
item_split = item_value.split('/')
item_key = '/'.join(item_split[:split_depth] , '/' )
if item_key not in sub_field_dict:
# Create property dict
......
......@@ -89,7 +89,7 @@ class URLOpener(FancyURLopener):
urltype, rest = splittype(selector)
url = rest
user_passwd = None
if string.lower(urltype) != 'http':
if urltype.lower() != 'http':
realhost = None
else:
realhost, rest = splithost(rest)
......@@ -101,7 +101,7 @@ class URLOpener(FancyURLopener):
if not host: raise IOError('http error', 'no host given')
if user_passwd:
import base64
auth = string.strip(base64.encodestring(user_passwd))
auth = base64.encodestring(user_passwd).strip()
else:
auth = None
h = httplib.HTTP(host)
......
......@@ -20,7 +20,7 @@ This tab can therefore not be used.
<dtml-if fields>
<tr>
<td colspan="3" class="form-title">
<dtml-var "_.string.capitalize(group)"> properties
<dtml-var group capitalize> properties
</td>
</tr>
......
......@@ -76,7 +76,7 @@ Surcharge <dtml-var meta_type> properties here.
<dtml-if fields>
<tr>
<td colspan="3" class="form-title">
<dtml-var "_.string.capitalize(group)"> properties
<dtml-var group capitalize> properties
</td>
</tr>
......
......@@ -78,7 +78,7 @@ This tab can therefore not be used.
<dtml-if fields>
<tr>
<td colspan="3" class="form-title">
<dtml-var "_.string.capitalize(group)"> properties
<dtml-var group capitalize> properties
</td>
</tr>
......
......@@ -14,7 +14,6 @@ from OFS.SimpleItem import Item
import Acquisition
from six.moves.urllib.parse import quote
import os
import string
from six import StringIO
from .Errors import ValidationError, FormValidationError, FieldDisabledError
......@@ -744,7 +743,7 @@ class ZMIForm(ObjectManager, PropertyManager, RoleManager, Item, Form):
fieldname -- the name of the field (meta_type) to add
Result -- empty string
"""
title = string.strip(title)
title = title.strip()
if not title:
title = id # title is always required, use id if not provided
# get the field class we want to add
......@@ -786,9 +785,9 @@ class ZMIForm(ObjectManager, PropertyManager, RoleManager, Item, Form):
try:
result = self.settings_form.validate_all(REQUEST)
except FormValidationError as e:
message = "Validation error(s).<br />" + string.join(
message = "Validation error(s).<br />" + "<br />".join(
["%s: %s" % (error.field.get_value('title'),
error.error_text) for error in e.errors], "<br />")
error.error_text) for error in e.errors])
return self.formSettings(self, REQUEST,
manage_tabs_message=message)
# if we need to switch encoding, get xml representation before setting
......@@ -906,7 +905,7 @@ class ZMIForm(ObjectManager, PropertyManager, RoleManager, Item, Form):
field_ids = self._get_field_ids(group, REQUEST)
if (to_group != 'Move to:' and
self.move_field_group(field_ids, group, to_group)):
fields = string.join(field_ids, ", ")
fields = ", ".join(field_ids)
message = "Fields %s transferred from %s to %s." % (fields,
group,
to_group)
......@@ -920,7 +919,7 @@ class ZMIForm(ObjectManager, PropertyManager, RoleManager, Item, Form):
def manage_add_group(self, new_group, REQUEST):
"""Adds a new group.
"""
group = string.strip(new_group)
group = new_group.strip()
if (group and group != 'Select group' and
self.add_group(group)):
message = "Group %s created." % (group)
......@@ -947,7 +946,7 @@ class ZMIForm(ObjectManager, PropertyManager, RoleManager, Item, Form):
"""Renames group.
"""
if 'new_name' in REQUEST:
new_name = string.strip(REQUEST['new_name'])
new_name = REQUEST['new_name'].strip()
if self.rename_group(group, new_name):
message = "Group %s renamed to %s." % (group, new_name)
else:
......
from __future__ import absolute_import
import string
from .DummyField import fields
from . import Widget, Validator
from .Field import ZMIField
......@@ -17,7 +16,7 @@ class ListTextAreaWidget(Widget.TextAreaWidget):
for element_text, element_value in value:
lines.append("%s | %s" % (element_text, element_value))
return Widget.TextAreaWidget.render(self, field, key,
string.join(lines, '\n'),
'\n'.join(lines),
REQUEST)
ListTextAreaWidgetInstance = ListTextAreaWidget()
......@@ -30,14 +29,14 @@ class ListLinesValidator(Validator.LinesValidator):
value = Validator.LinesValidator.validate(self, field, key, REQUEST)
result = []
for line in value:
elements = string.split(line, "|")
elements = line.split("|")
if len(elements) >= 2:
text, value = elements[:2]
else:
text = line
value = line
text = string.strip(text)
value = string.strip(value)
text = text.strip()
value = value.strip()
result.append((text, value))
return result
......
......@@ -3,7 +3,7 @@
<dtml-in get_groups>
<dtml-let group=sequence-item fields="get_fields_in_group(group)">
<dtml-if fields>
<h4><i><dtml-var "_.string.capitalize(group)"> properties</i></h4>
<h4><i><dtml-var group capitalize> properties</i></h4>
<dtml-in fields>
<dtml-let field=sequence-item>
<b><dtml-var "field.get_value('title')"> (<dtml-var "field.id">)</b>
......
......@@ -17,7 +17,7 @@ Edit <dtml-var meta_type> properties here.
<dtml-if fields>
<tr>
<td colspan="4" class="form-title">
<dtml-var "_.string.capitalize(group)"> properties
<dtml-var group capitalize> properties
</td>
</tr>
......
......@@ -14,7 +14,7 @@ Edit <dtml-var meta_type> method overrides here.
<dtml-if fields>
<tr>
<td colspan="3" class="form-title">
<dtml-var "_.string.capitalize(group)"> properties
<dtml-var group capitalize> properties
</td>
</tr>
......
......@@ -21,7 +21,7 @@ This tab can therefore not be used.
<dtml-if fields>
<tr>
<td colspan="3" class="form-title">
<dtml-var "_.string.capitalize(group)"> properties
<dtml-var group capitalize> properties
</td>
</tr>
......
......@@ -15,7 +15,6 @@ Original code from active state recipe
"""
__revision__ = '$Id: python.py 3661 2005-02-23 17:05:31Z tiran $'
import string
import keyword, token, tokenize
from six.moves import cStringIO as StringIO
......@@ -35,7 +34,7 @@ class Parser:
def __init__(self, raw, tags, out):
""" Store the source text.
"""
self.raw = string.strip(string.expandtabs(raw))
self.raw = raw.expandtabs().strip()
self.out = out
self.tags = tags
......@@ -46,7 +45,7 @@ class Parser:
self.lines = [0, 0]
pos = 0
while 1:
pos = string.find(self.raw, '\n', pos) + 1
pos = self.raw.find('\n', pos) + 1
if not pos: break
self.lines.append(pos)
self.lines.append(len(self.raw))
......
......@@ -49,7 +49,6 @@ from inspect import CO_VARKEYWORDS
from functools import wraps
import time
from six.moves import urllib
import string
import pprint
import re
import warnings
......@@ -1216,7 +1215,7 @@ class Catalog(Folder,
words = 0
obj = REQUEST.PARENTS[1]
path = string.join(obj.getPhysicalPath(), '/')
path = '/'.join(obj.getPhysicalPath())
results = self.aq_parent.ZopeFindAndApply(obj,
obj_metatypes=obj_metatypes,
......
......@@ -35,7 +35,7 @@ from AccessControl import ClassSecurityInfo
from DocumentTemplate.security import RestrictedDTML
from Products.CMFCore.utils import getToolByName
from Products.ERP5Type.Cache import clearCache
import string, sys
import sys
import time
from ZODB.POSException import ConflictError
......@@ -532,7 +532,7 @@ class ZCatalog(Folder, Persistent, Implicit):
def manage_edit(self, RESPONSE, URL1, threshold=1000, REQUEST=None):
""" edit the catalog """
if type(threshold) is not type(1):
threshold=string.atoi(threshold)
threshold=int(threshold)
self.threshold = threshold
RESPONSE.redirect(URL1 + '/manage_main?manage_tabs_message=Catalog%20Changed')
......@@ -616,7 +616,7 @@ class ZCatalog(Folder, Persistent, Implicit):
words = 0
obj = REQUEST.PARENTS[1]
path = string.join(obj.getPhysicalPath(), '/')
path = '/'.join(obj.getPhysicalPath())
results = self.ZopeFindAndApply(obj,
......@@ -1012,7 +1012,7 @@ class ZCatalog(Folder, Persistent, Implicit):
"""
Return the attribute names as a single string
"""
return string.join(self.names(sql_catalog_id=sql_catalog_id).get(column, ('',)),' ')
return ' '.join(self.names(sql_catalog_id=sql_catalog_id).get(column, ('',)))
def _searchable_arguments(self, sql_catalog_id=None):
catalog = self.getSQLCatalog(sql_catalog_id)
......@@ -1178,7 +1178,7 @@ class ZCatalog(Folder, Persistent, Implicit):
and
(not obj_searchterm or
(hasattr(ob, 'PrincipiaSearchSource') and
string.find(ob.PrincipiaSearchSource(), obj_searchterm) >= 0
ob.PrincipiaSearchSource().find(obj_searchterm) >= 0
))
and
(not obj_expr or expr_match(ob, obj_expr))
......@@ -1217,7 +1217,7 @@ class ZCatalog(Folder, Persistent, Implicit):
No exceptions are raised.
"""
script=REQUEST.script
if string.find(path, script) != 0:
if path.find(script) != 0:
path='%s/%s' % (script, path)
try:
return REQUEST.resolve_url(path)
......@@ -1267,7 +1267,7 @@ class ZCatalog(Folder, Persistent, Implicit):
if ob is None:
removed.append(path)
continue
ppath = string.join(ob.getPhysicalPath(), '/')
ppath = '/'.join(ob.getPhysicalPath())
if path != ppath:
fixed.append((path, ppath))
else:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment