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