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