Commit c7242932 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

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

parent 71a1aaf8
......@@ -26,7 +26,6 @@
##############################################################################
import os
from string import zfill
from urllib import urlencode
import tempfile
from DateTime import DateTime
......@@ -82,14 +81,14 @@ def printBarcodeSheet(self, sheet_number=1, input_list=[], test=False):
tempfile.tempdir = tempdir
if test:
#Fake list
input_list = os.linesep.join(['TEST%s' % zfill(b, 8) for b in range(1111111, 1111111 + ( row_number * column_number * sheet_number ))])
input_list = os.linesep.join(['TEST%s' % str(b).zfill(8) for b in range(1111111, 1111111 + ( row_number * column_number * sheet_number ))])
elif input_list not in ('', None):
if not isinstance(input_list, list):
input_list = os.linesep.join(map(escapeString, input_list.split(os.linesep)))
else:
input_list = os.linesep.join(input_list)
else:
input_list = os.linesep.join(['%s' % zfill(self.portal_ids.generateNewId(id_group='barcode'), 12) for b in range( row_number * column_number * sheet_number )])
input_list = os.linesep.join(['%s' % str(self.portal_ids.generateNewId(id_group='barcode')).zfill(12) for b in range( row_number * column_number * sheet_number )])
text_command = 'echo "%s" > %s' % (input_list, new_txt_file_path)
ret = os.system(text_command)
if ret != 0:
......
from string import zfill
return zfill(context.portal_ids.getLastGeneratedId(id_group='barcode'),12)
return str(context.portal_ids.getLastGeneratedId(id_group='barcode')).zfill(12)
......@@ -35,8 +35,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])
base_category = item_split[0]
multi = True
......
......@@ -30,8 +30,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])
base_category = item_split[0]
multi = False # XXX or now budget level are only single value.
......
from string import zfill
##################################################
#### About the transformation_rules structure ####
# a key indicate that input of that level having the same value must be grouped together
......
from string import zfill
##################################################
#### About the transformation_rules structure ####
# a key indicate that input of that level having the same value must be grouped together
......@@ -92,7 +90,7 @@ for upper_level_key in structured_input_data:
for second_level in structured_input_data[upper_level_key][1]:
second_level_id += 10
new_2nd_level_obj = new_1st_level_obj.newContent( portal_type = level_portal_types[1]
, id = zfill(second_level_id, 4)
, id = str(second_level_id).zfill(4)
)
for property_title in second_level.keys():
new_2nd_level_obj.setProperty(property_title, second_level[property_title])
......
from Products.ERP5Type.Document import newTempBase
from string import zfill
global portal_object, new_id, l
......@@ -14,7 +13,7 @@ def createInputLine():
int_len = 3
o = newTempBase( portal_object
, str(new_id)
, uid ='new_%s' % zfill(new_id, int_len)
, uid ='new_%s' % str(new_id).zfill(int_len)
)
l.append(o)
......
from string import zfill
destination_obj = context.getObject()
first_level_type = 'Use Case Scenario'
......
......@@ -28,7 +28,6 @@
from AccessControl import ClassSecurityInfo
from DateTime import DateTime
from string import capitalize
from erp5.component.module.DateUtils import centis, getClosestDate, addToDate
from erp5.component.module.DateUtils import getDecimalNumberOfYearsBetween
......@@ -99,7 +98,7 @@ class AmortisationRule(RuleMixin):
modified_properties = []
for (key, value) in calculated_movement.items():
if key not in ('name','status','id','divergent'):
getter_name = 'get%s' % ''.join([capitalize(o) for o in key.split('_')])
getter_name = 'get%s' % ''.join([o.capitalize() for o in key.split('_')])
getter = getattr(simulation_movement, getter_name)
previous_value = getter()
# Check if this property changes
......@@ -109,7 +108,7 @@ class AmortisationRule(RuleMixin):
if value is None and key.split('_')[-1] == 'value':
key = '_'.join(key.split('_')[:-1])
setter_name = 'set%s' % ''.join([capitalize(o) for o in key.split('_')])
setter_name = 'set%s' % ''.join([o.capitalize() for o in key.split('_')])
setter = getattr(simulation_movement, setter_name)
setter(value)
simulation_movement.edit(start_date=simulation_movement.getStopDate())
......
......@@ -5,9 +5,6 @@
# This script adds the needed actions in the Immobilisation portal_type, and
# each amortisable portal_type
from string import capitalize
def addAction(portal_type, portal_type_type, country, amortisation_method):
print 'Adding UI tab "Amortisation Details" for method %s on portal_type %s... ' % (amortisation_method,portal_type),
id = "%s_%s_amortisation_details_view" % (country, amortisation_method)
......@@ -22,8 +19,8 @@ def addAction(portal_type, portal_type_type, country, amortisation_method):
name = "Amortisation Details",
action = action,
condition = "object/IsUsing%s%sAmortisationMethod" % (
capitalize(country),
"".join([capitalize(x) for x in amortisation_method.split('_')]) ),
country.capitalize(),
"".join([x.capitalize() for x in amortisation_method.split('_')]) ),
permission = ('View',),
category = "object_view",
visible = 1)
......
from string import capitalize
view_id_basis = "%s_%s_amortisation_method_view_details"
view_action_basis = "Immobilisation_%s%sAmortisationMethodViewDetails"
view_condition_basis = "object/Immobilisation_isUsing%s%sAmortisationMethod"
......@@ -27,9 +25,9 @@ for method in amortisation_method_list:
exists = 1
if not exists:
capitalized_id = "".join([capitalize(o) for o in id.split("_")])
capitalized_id = "".join([o.capitalize() for o in id.split("_")])
action_action = view_action_basis % (region, capitalized_id)
action_condition = view_condition_basis % (capitalize(region),capitalized_id)
action_condition = view_condition_basis % (region.capitalize(), capitalized_id)
context.addAction(id = action_id,
name = "Amortisation Details",
action = action_action,
......
from Products.ERP5Type.Document import newTempBase
from string import zfill
portal_object = context.getPortalObject()
num = 0
......@@ -20,8 +19,8 @@ for [method_id, result] in result_list:
int_len = 7
if not result['success']:
o = newTempBase(portal_object, safe_id)
o.setUid( 'new_%s' % zfill(num, int_len)) # XXX There is a security issue here
o.edit(uid='new_%s' % zfill(num, int_len)) # XXX There is a security issue here
o.setUid( 'new_%s' % str(num).zfill(int_len)) # XXX There is a security issue here
o.edit(uid='new_%s' % str(num).zfill(int_len)) # XXX There is a security issue here
o.edit(**result['object'])
result_listbox.append(o)
......
from Products.ERP5Type.Document import newTempBase
from string import zfill
portal_object = context.getPortalObject()
num = 0
......@@ -25,8 +24,8 @@ for [method_id, result] in result_list:
num += 1
int_len = 3
o = newTempBase(portal_object, safe_id)
o.setUid( 'new_%s' % zfill(num, int_len)) # XXX There is a security issue here
o.edit(uid='new_%s' % zfill(num, int_len)) # XXX There is a security issue here
o.setUid( 'new_%s' % str(num).zfill(int_len)) # XXX There is a security issue here
o.edit(uid='new_%s' % str(num).zfill(int_len)) # XXX There is a security issue here
o.edit( method_id = method_id
, result = result['message']
, object_url = result['object_url']
......
from Products.ERP5Type.Document import newTempBase
from string import zfill
num = 0
listbox_lines = []
......@@ -23,8 +22,8 @@ for spreadsheet in spreadsheets.keys():
# int_len is used to fill the uid of the created object like 0000001
int_len = 7
o = newTempBase(context, safe_id)
o.setUid('new_%s' % zfill(num, int_len)) # XXX There is a security issue here
o.edit(uid='new_%s' % zfill(num, int_len)) # XXX There is a security issue here
o.setUid('new_%s' % str(num).zfill(int_len)) # XXX There is a security issue here
o.edit(uid='new_%s' % str(num).zfill(int_len)) # XXX There is a security issue here
o.edit(
id=safe_id,
spreadsheet_name=spreadsheet,
......
......@@ -11,8 +11,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])
base_category = item_split[0]
if item_key not in sub_field_dict:
# Create property dict
......
......@@ -11,8 +11,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
......
from Products.ERP5Type.Document import newTempBase
from string import zfill
portal_object = context.getPortalObject()
......@@ -15,7 +14,7 @@ def createInputLine(new_id):
int_len = 3
o = newTempBase( portal_object,
str(new_id),
uid ='new_%s' % zfill(new_id, int_len)
uid ='new_%s' % str(new_id).zfill(int_len)
)
l.append(o)
......
......@@ -5,7 +5,6 @@ information is correct.
portal = context.getPortalObject()
line_portal_type = "Sale Order Line"
request = context.REQUEST
from string import zfill
from Products.PythonScripts.standard import Object
from Products.ERP5Type.Message import translateString
......@@ -31,7 +30,7 @@ i = 1
project_search_dict = {}
for line in line_list:
line_dict = {}
key = zfill(i,3)
key = str(i).zfill(3)
for property_name in ('title', 'quantity_unit_title', 'quantity',
'resource_title', 'total_price', 'price',
'reference', 'relative_url'):
......
......@@ -17,8 +17,8 @@ for item in item_list:
# Get value of the item
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])
base_category = item_split[0]
sub_field_property_dict = sub_field_dict.setdefault(item_key, default_sub_field_property_dict.copy())
......
divergence_messages_list = context.getDivergenceList()
from Products.ERP5Type.Document import newTempBase
from string import zfill
portal_object = context.getPortalObject()
l = []
......@@ -13,7 +11,7 @@ def createInputLine(d_message, new_id):
o = newTempBase( portal_object
, str(new_id)
, uid ='new_%s' % zfill(new_id, int_len)
, uid ='new_%s' % str(new_id).zfill(int_len)
, message = str(d_message.getTranslatedMessage())
, tested_property_id = d_message.getProperty('tested_property')
, object_title = d_message.getObject().getTranslatedTitle()
......
......@@ -32,7 +32,6 @@ import zope.interface
from AccessControl import ClassSecurityInfo
from DateTime import DateTime
from string import capitalize
from Products.ERP5Type import Permissions, PropertySheet
from erp5.component.interface.IImmobilisationItem import IImmobilisationItem
......@@ -469,7 +468,7 @@ class ImmobilisableItem(Item, Amount):
property_list.extend(movement.getUncontinuousNeededSpecificParameterListForItem(self))
property_list.extend(movement.getFacultativeSpecificParameterListForItem(self))
for key,value,_ in property_list:
value = 'get' + ''.join(map(capitalize, value.split('_')))
value = 'get' + ''.join(e.capitalize() for e in value.split('_'))
value = getattr(movement, value, None)
if value is not None:
value = value()
......
......@@ -33,8 +33,6 @@ from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5Type.XMLObject import XMLObject
from erp5.component.document.Movement import Movement
from string import capitalize
UNIMMOBILISING_METHOD = "unimmobilise"
NO_CHANGE_METHOD = "no_change"
AMORTISATION_METHOD_PREFIX = "portal_skins/erp5_accounting_"
......@@ -103,7 +101,7 @@ class ImmobilisationMovement(Movement, XMLObject):
def checkValuesAreNotNone(property_list):
errors = []
for key, value, name in property_list:
value = 'get' + ''.join(map(capitalize, value.split('_')))
value = 'get' + ''.join(capitalize(e) for e in value.split('_'))
value = getattr(self, value, None)
if value is not None:
value = value()
......
......@@ -339,7 +339,6 @@ class DB(TM):
c = self._query('SHOW COLUMNS FROM %s' % table_name)
except Exception:
return ()
from string import join
r=[]
for Field, Type, Null, Key, Default, Extra in c.fetch_row(0):
info = {}
......@@ -363,7 +362,7 @@ class DB(TM):
info['Name'] = Field
info['Type'] = type_xlate.get(short_type,'string')
info['Extra'] = Extra,
info['Description'] = join([Type, field_default, Extra or '',
info['Description'] = ' '.join([Type, field_default, Extra or '',
key_types.get(Key, Key or ''),
Null != 'YES' and 'NOT NULL' or '']),
info['Nullable'] = Null == 'YES'
......
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