Commit 2f814c94 authored by Arnaud Fontaine's avatar Arnaud Fontaine

py3: string.zfill() was removed.

parent dcaffa0b
...@@ -31,7 +31,6 @@ from builtins import str ...@@ -31,7 +31,6 @@ from builtins import str
from builtins import map from builtins import map
from builtins import range from builtins import range
import os import os
from string import zfill
from urllib.parse import urlencode from urllib.parse import urlencode
import tempfile import tempfile
from DateTime import DateTime from DateTime import DateTime
...@@ -87,14 +86,14 @@ def printBarcodeSheet(self, sheet_number=1, input_list=[], test=False): ...@@ -87,14 +86,14 @@ def printBarcodeSheet(self, sheet_number=1, input_list=[], test=False):
tempfile.tempdir = tempdir tempfile.tempdir = tempdir
if test: if test:
#Fake list #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%08d' % b for b in range(1111111, 1111111 + ( row_number * column_number * sheet_number ))])
elif input_list not in ('', None): elif input_list not in ('', None):
if not isinstance(input_list, list): if not isinstance(input_list, list):
input_list = os.linesep.join(map(escapeString, input_list.split(os.linesep))) input_list = os.linesep.join(map(escapeString, input_list.split(os.linesep)))
else: else:
input_list = os.linesep.join(input_list) input_list = os.linesep.join(input_list)
else: 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(['%012d' % self.portal_ids.generateNewId(id_group='barcode') for b in range( row_number * column_number * sheet_number )])
text_command = 'echo "%s" > %s' % (input_list, new_txt_file_path) text_command = 'echo "%s" > %s' % (input_list, new_txt_file_path)
ret = os.system(text_command) ret = os.system(text_command)
if ret != 0: if ret != 0:
......
from string import zfill return "%012d" % context.portal_ids.getLastGeneratedId(id_group='barcode')
return zfill(context.portal_ids.getLastGeneratedId(id_group='barcode'),12)
from __future__ import print_function from __future__ import print_function
from past.builtins import cmp from past.builtins import cmp
from builtins import range from builtins import range
from string import zfill
################################################## ##################################################
#### About the transformation_rules structure #### #### About the transformation_rules structure ####
......
from past.builtins import cmp from past.builtins import cmp
from string import zfill
################################################## ##################################################
#### About the transformation_rules structure #### #### About the transformation_rules structure ####
...@@ -93,7 +92,7 @@ for upper_level_key in structured_input_data: ...@@ -93,7 +92,7 @@ for upper_level_key in structured_input_data:
for second_level in structured_input_data[upper_level_key][1]: for second_level in structured_input_data[upper_level_key][1]:
second_level_id += 10 second_level_id += 10
new_2nd_level_obj = new_1st_level_obj.newContent( portal_type = level_portal_types[1] new_2nd_level_obj = new_1st_level_obj.newContent( portal_type = level_portal_types[1]
, id = zfill(second_level_id, 4) , id = "%04d" % second_level_id
) )
for property_title in list(second_level.keys()): for property_title in list(second_level.keys()):
new_2nd_level_obj.setProperty(property_title, second_level[property_title]) new_2nd_level_obj.setProperty(property_title, second_level[property_title])
......
from builtins import str from builtins import str
from builtins import range from builtins import range
from Products.ERP5Type.Document import newTempBase from Products.ERP5Type.Document import newTempBase
from string import zfill
global portal_object, new_id, l global portal_object, new_id, l
...@@ -14,9 +13,10 @@ def createInputLine(): ...@@ -14,9 +13,10 @@ def createInputLine():
global portal_object, new_id, l global portal_object, new_id, l
new_id += 1 new_id += 1
int_len = 3 int_len = 3
new_id_str = str(new_id)
o = newTempBase( portal_object o = newTempBase( portal_object
, str(new_id) , new_id_str
, uid ='new_%s' % zfill(new_id, int_len) , uid ='new_' + new_id_str.zfill(int_len)
) )
l.append(o) l.append(o)
......
from past.builtins import cmp from past.builtins import cmp
from string import zfill
destination_obj = context.getObject() destination_obj = context.getObject()
......
from Products.ERP5Type.Document import newTempBase from Products.ERP5Type.Document import newTempBase
from string import zfill
portal_object = context.getPortalObject() portal_object = context.getPortalObject()
num = 0 num = 0
...@@ -19,9 +18,10 @@ for [method_id, result] in result_list: ...@@ -19,9 +18,10 @@ for [method_id, result] in result_list:
num += 1 num += 1
int_len = 7 int_len = 7
if not result['success']: if not result['success']:
uid = 'new_' + str(num).zfill(int_len)
o = newTempBase(portal_object, safe_id) o = newTempBase(portal_object, safe_id)
o.setUid( 'new_%s' % zfill(num, int_len)) # XXX There is a security issue here o.setUid(uid) # XXX There is a security issue here
o.edit(uid='new_%s' % zfill(num, int_len)) # XXX There is a security issue here o.edit(uid=uid) # XXX There is a security issue here
o.edit(**result['object']) o.edit(**result['object'])
result_listbox.append(o) result_listbox.append(o)
......
from Products.ERP5Type.Document import newTempBase from Products.ERP5Type.Document import newTempBase
from string import zfill
portal_object = context.getPortalObject() portal_object = context.getPortalObject()
num = 0 num = 0
...@@ -24,9 +23,10 @@ for [method_id, result] in result_list: ...@@ -24,9 +23,10 @@ for [method_id, result] in result_list:
safe_id = context.Base_getSafeIdFromString('result %s' % num) safe_id = context.Base_getSafeIdFromString('result %s' % num)
num += 1 num += 1
int_len = 3 int_len = 3
uid = 'new_' + str(num).zfill(int_len)
o = newTempBase(portal_object, safe_id) o = newTempBase(portal_object, safe_id)
o.setUid( 'new_%s' % zfill(num, int_len)) # XXX There is a security issue here o.setUid(uid) # XXX There is a security issue here
o.edit(uid='new_%s' % zfill(num, int_len)) # XXX There is a security issue here o.edit(uid=uid) # XXX There is a security issue here
o.edit( method_id = method_id o.edit( method_id = method_id
, result = result['message'] , result = result['message']
, object_url = result['object_url'] , object_url = result['object_url']
......
from Products.ERP5Type.Document import newTempBase from Products.ERP5Type.Document import newTempBase
from string import zfill
num = 0 num = 0
listbox_lines = [] listbox_lines = []
...@@ -23,8 +22,9 @@ for spreadsheet in list(spreadsheets.keys()): ...@@ -23,8 +22,9 @@ for spreadsheet in list(spreadsheets.keys()):
# int_len is used to fill the uid of the created object like 0000001 # int_len is used to fill the uid of the created object like 0000001
int_len = 7 int_len = 7
o = newTempBase(context, safe_id) o = newTempBase(context, safe_id)
o.setUid('new_%s' % zfill(num, int_len)) # XXX There is a security issue here uid = 'new_' + str(num).zfill(int_len)
o.edit(uid='new_%s' % zfill(num, int_len)) # XXX There is a security issue here o.setUid(uid) # XXX There is a security issue here
o.edit(uid=uid) # XXX There is a security issue here
o.edit( o.edit(
id=safe_id, id=safe_id,
spreadsheet_name=spreadsheet, spreadsheet_name=spreadsheet,
......
from builtins import str from builtins import str
from builtins import range from builtins import range
from Products.ERP5Type.Document import newTempBase from Products.ERP5Type.Document import newTempBase
from string import zfill
portal_object = context.getPortalObject() portal_object = context.getPortalObject()
...@@ -15,9 +14,10 @@ l = [] ...@@ -15,9 +14,10 @@ l = []
# function to create a new fast input line # function to create a new fast input line
def createInputLine(new_id): def createInputLine(new_id):
int_len = 3 int_len = 3
new_id_str = str(new_id)
o = newTempBase( portal_object, o = newTempBase( portal_object,
str(new_id), new_id_str,
uid ='new_%s' % zfill(new_id, int_len) uid ='new_' + new_id_str.zfill(int_len)
) )
l.append(o) l.append(o)
......
...@@ -6,7 +6,6 @@ context.log('source_project_title', source_project_title) ...@@ -6,7 +6,6 @@ context.log('source_project_title', source_project_title)
portal = context.getPortalObject() portal = context.getPortalObject()
line_portal_type = "Sale Order Line" line_portal_type = "Sale Order Line"
request = context.REQUEST request = context.REQUEST
from string import zfill
from Products.ERP5Type.Document import newTempBase from Products.ERP5Type.Document import newTempBase
from Products.ERP5Type.Message import translateString from Products.ERP5Type.Message import translateString
...@@ -36,7 +35,7 @@ portal = context.getPortalObject() ...@@ -36,7 +35,7 @@ portal = context.getPortalObject()
for line in line_list: for line in line_list:
line_dict = {} line_dict = {}
#line_dict['listbox_key'] = "%s" % line_id #line_dict['listbox_key'] = "%s" % line_id
key = zfill(i,3) key = "%03d" % i
for property_name in ('title', 'quantity_unit_title', 'quantity', for property_name in ('title', 'quantity_unit_title', 'quantity',
'resource_title', 'total_price', 'price', 'resource_title', 'total_price', 'price',
'reference', 'relative_url'): 'reference', 'relative_url'):
......
...@@ -2,7 +2,6 @@ from builtins import str ...@@ -2,7 +2,6 @@ from builtins import str
divergence_messages_list = context.getDivergenceList() divergence_messages_list = context.getDivergenceList()
from Products.ERP5Type.Document import newTempBase from Products.ERP5Type.Document import newTempBase
from string import zfill
portal_object = context.getPortalObject() portal_object = context.getPortalObject()
...@@ -11,10 +10,10 @@ l = [] ...@@ -11,10 +10,10 @@ l = []
# function to create a new fast input line # function to create a new fast input line
def createInputLine(d_message, new_id): def createInputLine(d_message, new_id):
int_len = 3 int_len = 3
new_id_str = str(new_id)
o = newTempBase( portal_object o = newTempBase( portal_object
, str(new_id) , str(new_id)
, uid ='new_%s' % zfill(new_id, int_len) , uid ='new_' + new_id_str.zfill(int_len)
, message = str(d_message.getTranslatedMessage()) , message = str(d_message.getTranslatedMessage())
, tested_property_id = d_message.getProperty('tested_property') , tested_property_id = d_message.getProperty('tested_property')
, object_title = d_message.getObject().getTranslatedTitle() , object_title = d_message.getObject().getTranslatedTitle()
......
...@@ -34,7 +34,6 @@ import warnings ...@@ -34,7 +34,6 @@ import warnings
from AccessControl import ModuleSecurityInfo from AccessControl import ModuleSecurityInfo
from DateTime import DateTime from DateTime import DateTime
from datetime import datetime from datetime import datetime
from string import zfill
security = ModuleSecurityInfo(__name__) security = ModuleSecurityInfo(__name__)
security.declarePublic('addToDate', 'getClosestDate', security.declarePublic('addToDate', 'getClosestDate',
...@@ -495,7 +494,7 @@ def atTheEndOfPeriod(date, period): ...@@ -495,7 +494,7 @@ def atTheEndOfPeriod(date, period):
if period == 'year': if period == 'year':
end = addToDate(DateTime('%s/01/01 00:00:00 %s' % (date.year(), date.timezone())), **{period:1}) end = addToDate(DateTime('%s/01/01 00:00:00 %s' % (date.year(), date.timezone())), **{period:1})
elif period == 'month': elif period == 'month':
end = addToDate(DateTime('%s/%s/01 00:00:00 %s' % (date.year(), zfill(date.month(), 2), date.timezone())), **{period:1}) end = addToDate(DateTime('%s/%02d/01 00:00:00 %s' % (date.year(), date.month(), date.timezone())), **{period:1})
elif period == 'day': elif period == 'day':
end = addToDate(date.earliestTime(), hour=36).earliestTime() end = addToDate(date.earliestTime(), hour=36).earliestTime()
elif period == 'week': elif period == 'week':
......
from builtins import str from builtins import str
from Products.ERP5Type.Message import translateString from Products.ERP5Type.Message import translateString
from Products.ERP5Type.Document import newTempBase from Products.ERP5Type.Document import newTempBase
from string import zfill
portal = context.getPortalObject() portal = context.getPortalObject()
request = context.REQUEST request = context.REQUEST
domain_list = [] domain_list = []
...@@ -29,7 +28,7 @@ if depth == 0: ...@@ -29,7 +28,7 @@ if depth == 0:
# 0.125 means 3 hours in DateTime float format # 0.125 means 3 hours in DateTime float format
while current_date < bound_stop: while current_date < bound_stop:
# Create one Temp Object # Create one Temp Object
o = newTempBase(portal, id='year', uid='new_%s' % zfill('year',4)) o = newTempBase(portal, id='year', uid='new_year')
# Setting Axis Dates start and stop # Setting Axis Dates start and stop
o.setProperty('start',current_date) o.setProperty('start',current_date)
o.setProperty('stop', current_date + 0.125) o.setProperty('stop', current_date + 0.125)
......
...@@ -7,7 +7,6 @@ from past.utils import old_div ...@@ -7,7 +7,6 @@ from past.utils import old_div
from Products.ERP5Type.Message import Message from Products.ERP5Type.Message import Message
from Products.ERP5Type.Document import newTempBase from Products.ERP5Type.Document import newTempBase
from Products.PythonScripts.standard import url_quote from Products.PythonScripts.standard import url_quote
from string import zfill
portal = context.getPortalObject() portal = context.getPortalObject()
request = context.REQUEST request = context.REQUEST
domain_list = [] domain_list = []
...@@ -50,7 +49,7 @@ if depth == 0: ...@@ -50,7 +49,7 @@ if depth == 0:
while current_date < axis_stop: while current_date < axis_stop:
# Create one Temp Object # Create one Temp Object
o = newTempBase(portal, id=str(current_date.Day()), o = newTempBase(portal, id=str(current_date.Day()),
uid='new_%s' % zfill('year',4)) uid='new_year')
# Setting Axis Dates start and stop # Setting Axis Dates start and stop
o.setProperty('start',current_date) o.setProperty('start',current_date)
......
...@@ -5,7 +5,6 @@ from builtins import str ...@@ -5,7 +5,6 @@ from builtins import str
from Products.ERP5Type.Message import translateString from Products.ERP5Type.Message import translateString
from Products.ERP5Type.Document import newTempBase from Products.ERP5Type.Document import newTempBase
from Products.PythonScripts.standard import url_quote from Products.PythonScripts.standard import url_quote
from string import zfill
portal = context.getPortalObject() portal = context.getPortalObject()
request = context.REQUEST request = context.REQUEST
...@@ -40,7 +39,7 @@ if depth == 0: ...@@ -40,7 +39,7 @@ if depth == 0:
# This case show Seven days # This case show Seven days
while current_date < bound_stop: while current_date < bound_stop:
# Create one Temp Object # Create one Temp Object
o = newTempBase(portal, id='week', uid='new_%s' % zfill('week',4)) o = newTempBase(portal, id='week', uid='new_week')
# Setting Axis Dates start and stop # Setting Axis Dates start and stop
o.setProperty('start',current_date) o.setProperty('start',current_date)
o.setProperty('stop', current_date+1) o.setProperty('stop', current_date+1)
......
...@@ -5,7 +5,6 @@ from builtins import str ...@@ -5,7 +5,6 @@ from builtins import str
from Products.ERP5Type.Message import translateString from Products.ERP5Type.Message import translateString
from Products.ERP5Type.Document import newTempBase from Products.ERP5Type.Document import newTempBase
from Products.PythonScripts.standard import url_quote from Products.PythonScripts.standard import url_quote
from string import zfill
portal = context.getPortalObject() portal = context.getPortalObject()
request = context.REQUEST request = context.REQUEST
...@@ -28,7 +27,7 @@ if depth == 0: ...@@ -28,7 +27,7 @@ if depth == 0:
count = 0 count = 0
while count < 12: while count < 12:
# Create one Temp Object # Create one Temp Object
o = newTempBase(portal, id='year', uid='new_%s' % zfill('year',4)) o = newTempBase(portal, id='year', uid='new_year')
# Setting delimiter # Setting delimiter
if current_date.month() in [1, 7]: if current_date.month() in [1, 7]:
o.setProperty('delimiter_type', 1) o.setProperty('delimiter_type', 1)
......
from builtins import str from builtins import str
from string import zfill
request = context.REQUEST request = context.REQUEST
if kw.get('update', False): if kw.get('update', False):
...@@ -17,7 +16,7 @@ for k in list(kw.keys()): ...@@ -17,7 +16,7 @@ for k in list(kw.keys()):
if listbox_key in line: if listbox_key in line:
key = '%s' % line[listbox_key] key = '%s' % line[listbox_key]
else: else:
key = str(zfill(i,3)) key = '%03d' % i
listbox[key] = line listbox[key] = line
i+=1 i+=1
request.set(k,listbox) request.set(k,listbox)
......
from builtins import str from builtins import str
from builtins import range from builtins import range
from Products.ERP5Type.Document import newTempBase from Products.ERP5Type.Document import newTempBase
from string import zfill
if listbox_id is None: if listbox_id is None:
listbox_id = 'listbox' listbox_id = 'listbox'
...@@ -30,7 +29,7 @@ if hasattr(request, listbox_id): ...@@ -30,7 +29,7 @@ if hasattr(request, listbox_id):
for i in keys_list: for i in keys_list:
o = newTempBase(portal_object, i) o = newTempBase(portal_object, i)
o.setUid('new_%s' % zfill(i,int_len)) o.setUid('new_%s' % str(i).zfill(int_len))
is_empty = 1 is_empty = 1
...@@ -52,7 +51,7 @@ if not('field_errors' in request): ...@@ -52,7 +51,7 @@ if not('field_errors' in request):
for i in range(first_empty_line_id,first_empty_line_id+empty_line_number): for i in range(first_empty_line_id,first_empty_line_id+empty_line_number):
o = newTempBase(portal_object, str(i)) o = newTempBase(portal_object, str(i))
o.setUid('new_%s' % zfill(i,int_len)) o.setUid('new_%s' % str(i).zfill(int_len))
# zfill is used here to garantee sort order - XXX - cleaner approach required # zfill is used here to garantee sort order - XXX - cleaner approach required
l.append(o) l.append(o)
......
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