Commit f6174c91 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki Committed by Jérome Perrin

py2/py3: modernize -f xrange_six.

parent e56e03d2
......@@ -16,6 +16,7 @@
"""
from DateTime import DateTime
from Products.CMFActivity.ActiveResult import ActiveResult
from six.moves import range
active_result = ActiveResult()
portal = context.getPortalObject()
activate = portal.portal_activities.activate
......@@ -54,7 +55,7 @@ if catalog_uid_list is None:
'tag': tag,
'fixit': fixit,
}
for _ in xrange(activity_count):
for _ in range(activity_count):
if len(catalog_uid_list) == 0:
result_list.append('No more uids to check, stop spawning activities.')
break
......
from Products.ERP5Type.Core.Workflow import ValidationFailed
from Products.ERP5Type.Message import Message
from six.moves import range
# Check new catalog or catalog is the same as previous archive
# Check date
......@@ -25,7 +26,7 @@ if archive.getStopDateRangeMax() is not None:
if len(previous_archive_list) > 0:
# Check the date
for x in xrange(len(previous_archive_list)):
for x in range(len(previous_archive_list)):
previous_archive = previous_archive_list[x]
# find a previous archive which was not for current catalog
if previous_archive.getStopDateRangeMax() is not None:
......@@ -40,7 +41,7 @@ else:
if len(previous_archive_list) > 0:
# Check the date
for x in xrange(len(previous_archive_list)):
for x in range(len(previous_archive_list)):
previous_archive = previous_archive_list[x]
# find a previous archive which was not for current catalog
if previous_archive.getStopDateRangeMax() is not None:
......
from BTrees.LOBTree import LOBTree
from persistent import Persistent
import itertools
from six.moves import range
# Maximum memory to allocate for sparse-induced padding.
MAX_PADDING_CHUNK = 2 ** 20
......@@ -418,22 +419,22 @@ if __name__ == '__main__':
check(data, 36, 0, 36, '01ABC56789ABcDEFGHIJKL\x00NOPQRSTUVWXYZ', [0, 10, 20, 23, 33])
data = BTreeData(max_chunk_size=10)
for x in xrange(255):
for x in range(255):
data.write('%02x' % x, x * 2)
check(data, 510, 0, 10, '0001020304', [x * 2 for x in xrange(255)])
check(data, 510, 0, 10, '0001020304', [x * 2 for x in range(255)])
defragment_generator = data.defragment(batch_size=2)
defragment_generator.next()
check(data, 510, 0, 10, '0001020304', [0] + [x * 2 for x in xrange(2, 255)])
check(data, 510, 0, 10, '0001020304', [0] + [x * 2 for x in range(2, 255)])
opaque = defragment_generator.next()
defragment_generator.close()
check(data, 510, 0, 10, '0001020304', [0] + [x * 2 for x in xrange(4, 255)])
check(data, 510, 0, 10, '0001020304', [0] + [x * 2 for x in range(4, 255)])
defragment_generator = data.defragment(batch_size=2, resume_at=opaque)
defragment_generator.next()
check(data, 510, 0, 10, '0001020304', [0] + [x * 2 for x in xrange(5, 255)])
check(data, 510, 0, 10, '0001020304', [0] + [x * 2 for x in range(5, 255)])
defragment_generator.send(10)
check(data, 510, 0, 10, '0001020304', [0, 10, 20] + [x * 2 for x in xrange(13, 255)])
check(data, 510, 0, 10, '0001020304', [0, 10, 20] + [x * 2 for x in range(13, 255)])
defragment_generator.next()
check(data, 510, 0, 10, '0001020304', [0, 10, 20, 30, 40] + [x * 2 for x in xrange(23, 255)])
check(data, 510, 0, 10, '0001020304', [0, 10, 20, 30, 40] + [x * 2 for x in range(23, 255)])
for _ in defragment_generator:
pass
check(data, 510, 0, 10, '0001020304', [x * 10 for x in xrange(51)])
check(data, 510, 0, 10, '0001020304', [x * 10 for x in range(51)])
......@@ -47,6 +47,7 @@ import tempfile
import glob
import sys
from OFS.Image import Pdata
from six.moves import range
WORKFLOW_TYPE = 'erp5_workflow'
......@@ -644,7 +645,7 @@ class BusinessTemplateMixin(ERP5TypeTestCase, LogInterceptor):
module.manage_permission('Copy or Move', ['Assignor'], False)
sequence.edit(module_id=module.getId())
module_object_list = []
for _ in xrange(10):
for _ in range(10):
obj = module.newContent(portal_type = 'Geek Object')
self.assertIsNotNone(obj)
module_object_list.append(obj)
......@@ -668,7 +669,7 @@ class BusinessTemplateMixin(ERP5TypeTestCase, LogInterceptor):
module = portal._getOb(module_id, None)
self.assertIsNotNone(module)
module_object_list = []
for _ in xrange(10):
for _ in range(10):
obj = module.newContent(portal_type = 'Geek Object')
self.assertIsNotNone(obj)
module_object_list.append(obj.getId())
......@@ -1216,7 +1217,7 @@ class BusinessTemplateMixin(ERP5TypeTestCase, LogInterceptor):
base_category = pc._getOb(bc_id, None)
self.assertTrue(base_category is not None)
category_list = []
for _ in xrange(10):
for _ in range(10):
category = base_category.newContent(portal_type='Category')
category_list.append(category.getId())
sequence.edit(category_id_list=category_list)
......@@ -1283,7 +1284,7 @@ class BusinessTemplateMixin(ERP5TypeTestCase, LogInterceptor):
self.assertTrue(category is not None)
subcategory_list = []
subcategory_uid_dict = {}
for _ in xrange(10):
for _ in range(10):
subcategory = category.newContent(portal_type='Category', title='toto')
subcategory_list.append(subcategory.getId())
subcategory_uid_dict[subcategory.getId()] = subcategory.getUid()
......@@ -3084,7 +3085,7 @@ class BusinessTemplateMixin(ERP5TypeTestCase, LogInterceptor):
def stepCreateFakeZODBScript(self, sequence=None, **kw):
"""Create a Script inside portal_skins
"""
grain_of_sand = ''.join([random.choice(string.ascii_letters) for _ in xrange(10)])
grain_of_sand = ''.join([random.choice(string.ascii_letters) for _ in range(10)])
python_script_id = 'ERP5Site_dummyScriptWhichRandomId%s' % grain_of_sand
skin_folder_id = 'custom'
if getattr(self.portal.portal_skins, skin_folder_id, None) is None:
......
......@@ -47,6 +47,7 @@ from Products.PageTemplates.Expressions import getEngine
from Products.ZSQLCatalog.SQLCatalog import Query, ComplexQuery, SimpleQuery
from Testing import ZopeTestCase
from zLOG import LOG
from six.moves import range
def format_stack(thread=None):
frame_dict = sys._current_frames()
......@@ -586,7 +587,7 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
portal_catalog = self.getCatalogTool()
from Products.ZSQLCatalog.SQLCatalog import UID_BUFFER_SIZE
uid_dict = {}
for _ in xrange(UID_BUFFER_SIZE * 3):
for _ in range(UID_BUFFER_SIZE * 3):
uid = portal_catalog.newUid()
self.assertTrue(isinstance(uid, long))
self.assertNotIn(uid, uid_dict)
......@@ -1285,7 +1286,7 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
old_default_result_limit = ctool.default_result_limit
max_ = ctool.default_result_limit = 3
#Create max + 2 Organisations
for i in xrange(max_ + 2):
for i in range(max_ + 2):
self._makeOrganisation(title='abc%s' % (i), description='abc')
self.assertEqual(max_,
len(self.getCatalogTool()(portal_type='Organisation')))
......@@ -4064,7 +4065,7 @@ VALUES
now = DateTime()
try:
organisation_list = []
for _ in xrange(0,300):
for _ in range(0,300):
organisation_list.append(
self.portal.organisation_module.newContent().getPath())
self.tic()
......
......@@ -37,6 +37,7 @@ from Products.ERP5Type.Cache import clearCache
from Products.ERP5Type.Core.Folder import FragmentedLength, FRAGMENTED_LENGTH_THRESHOLD
from AccessControl.ZopeGuards import guarded_getattr
from zExceptions import Unauthorized
from six.moves import range
class TestFolder(ERP5TypeTestCase, LogInterceptor):
......@@ -108,7 +109,7 @@ class TestFolder(ERP5TypeTestCase, LogInterceptor):
'return %s[len(context)]' % (repr(id_generator_id_list), ))
self.folder.setIdGenerator(id_generator_script_name)
self.assertEqual(self.folder.getIdGenerator(), id_generator_script_name)
for expected_length in xrange(len(id_generator_id_list)):
for expected_length in range(len(id_generator_id_list)):
self.assertEqual(len(self.folder), expected_length)
obj = self.newContent()
self.assertEqual(obj.getId(), id_generator_id_list[expected_length])
......@@ -278,7 +279,7 @@ class TestFolder(ERP5TypeTestCase, LogInterceptor):
self.assertEqual(len(folder), 1)
self.assertIsInstance(folder_dict['_count'], Length)
original_length_oid = folder_dict['_count']._p_oid
for _ in xrange(FRAGMENTED_LENGTH_THRESHOLD - len(folder) - 1):
for _ in range(FRAGMENTED_LENGTH_THRESHOLD - len(folder) - 1):
folder.newContent(portal_type='Folder')
self.assertEqual(len(folder), FRAGMENTED_LENGTH_THRESHOLD - 1)
self.assertIsInstance(folder_dict['_count'], Length)
......
......@@ -33,6 +33,7 @@ import unittest
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.utils import createZODBPythonScript
from MySQLdb import ProgrammingError
from six.moves import range
class TestIdTool(ERP5TypeTestCase):
......@@ -389,14 +390,14 @@ class TestIdTool(ERP5TypeTestCase):
A_LOT_OF_KEY = 2500
var_id = 'C-%04d'
for x in xrange(A_LOT_OF_KEY):
for x in range(A_LOT_OF_KEY):
self.assertEqual(0, self.id_tool.generateNewId(id_generator=id_generator,
id_group=var_id % x))
# test before update
self.assertEqual(None, sql_generator.last_max_id_dict.get('A-08'))
self.assertEqual(None, sql_generator.last_max_id_dict.get('B-08'))
for x in xrange(A_LOT_OF_KEY):
for x in range(A_LOT_OF_KEY):
self.assertEqual(None, sql_generator.last_max_id_dict.get(var_id % x))
createZODBPythonScript(
self.portal.portal_skins.custom,
......@@ -420,7 +421,7 @@ if new_last_id_group is not None:
# asserts
self.assertEqual(2, sql_generator.last_max_id_dict['A-08'].value)
self.assertEqual(1, sql_generator.last_max_id_dict['B-08'].value)
for x in xrange(A_LOT_OF_KEY):
for x in range(A_LOT_OF_KEY):
self.assertEqual(0, sql_generator.last_max_id_dict[var_id % x].value)
def test_decentralised_ZODB_id_generator(self):
......
......@@ -34,6 +34,7 @@ from Products.ERP5Type.Globals import PersistentMapping
from Products.ERP5Type.Utils import ScalarMaxConflictResolver
from BTrees.Length import Length
from BTrees.OOBTree import OOBTree
from six.moves import range
class TestIdToolUpgrade(ERP5TypeTestCase):
......@@ -173,14 +174,14 @@ class TestIdToolUpgrade(ERP5TypeTestCase):
def _setUpLastMaxIdDict(self, id_generator_reference):
def countup(id_generator, id_group, until):
for _ in xrange(until + 1):
for _ in range(until + 1):
self.id_tool.generateNewId(id_generator=id_generator_reference,
id_group=id_group)
countup(id_generator_reference, 'A-01', 2)
countup(id_generator_reference, 'B-01', 1)
var_id = 'C-%04d'
for x in xrange(self.a_lot_of_key):
for x in range(self.a_lot_of_key):
countup(id_generator_reference, var_id % x, 0)
def _getLastIdDictName(self, id_generator):
......@@ -214,7 +215,7 @@ class TestIdToolUpgrade(ERP5TypeTestCase):
last_id_dict = self._getLastIdDict(id_generator)
self.assertEqual(2, self._getValueFromLastIdDict(last_id_dict, 'A-01'))
self.assertEqual(1, self._getValueFromLastIdDict(last_id_dict, 'B-01'))
for x in xrange(self.a_lot_of_key):
for x in range(self.a_lot_of_key):
key = 'C-%04d' % x
self.assertEqual(0, self._getValueFromLastIdDict(last_id_dict, key))
......
......@@ -33,6 +33,7 @@ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from AccessControl.SecurityManagement import newSecurityManager
from zLOG import LOG
from Products.ERP5Type.tests.Sequence import SequenceList
from six.moves import range
class TestTrashTool(ERP5TypeTestCase):
......@@ -76,7 +77,7 @@ class TestTrashTool(ERP5TypeTestCase):
base_category = pc._getOb(bc_id, None)
self.assertTrue(base_category is not None)
category_list = []
for _ in xrange(10):
for _ in range(10):
category = base_category.newContent(portal_type='Category')
category_list.append(category.getId())
sequence.edit(category_id_list=category_list)
......
......@@ -34,6 +34,7 @@ from Products.ERP5Type.Workflow import WorkflowHistoryList
from Products.ERP5Type.patches.WorkflowTool import \
WorkflowHistoryList as LegacyWorkflowHistoryList
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from six.moves import range
orig_maybe_rotate = DoublyLinkList._maybe_rotate.__func__
......@@ -73,7 +74,7 @@ def old(items):
return whl
COUNT = 45
EXPECTED = range(COUNT)
EXPECTED = list(range(COUNT))
class TestWorkflowHistoryList(TestCase):
......@@ -101,7 +102,7 @@ class TestWorkflowHistoryList(TestCase):
check = check()
i = COUNT + 1
for i in xrange(-i, i):
for i in range(-i, i):
_ = check[i]
_ = check[-50:10]
_ = check[:20:3]
......@@ -129,7 +130,7 @@ class TestWorkflowHistoryList(TestCase):
@fixed_count_bucket
def test_01_DoublyLinkList(self):
self.checkList(new(DoublyLinkList, range(COUNT)))
self.checkList(new(DoublyLinkList, list(range(COUNT))))
@fixed_count_bucket
def test_02_LegacyWorkflowHistoryList(self):
......@@ -159,13 +160,13 @@ class TestWorkflowHistoryList(TestCase):
self.assertIs(prev, whl._prev)
self.assertEqual(slots, EXPECTED[32:])
whl += xrange(3)
whl += range(3)
self.checkClass(whl, LegacyWorkflowHistoryList)
whl += xrange(2)
whl += range(2)
self.checkClass(whl, WorkflowHistoryList)
self.abort()
whl += xrange(3)
whl += range(3)
self.checkClass(whl, LegacyWorkflowHistoryList)
whl.append('foo')
whl.append('bar')
......@@ -186,8 +187,8 @@ class TestWorkflowHistoryList(TestCase):
def test_04_rotation(self):
self.app.ddl = ddl = DoublyLinkList()
item_size = ddl._bucket_size // 3
for _ in xrange(3):
for _ in xrange(3):
for _ in range(3):
for _ in range(3):
ddl.append('.' * item_size)
self.commit()
self.assertEqual(6, ddl._tail_count)
......
from Products.PythonScripts.standard import Object
from six.moves import range
request = container.REQUEST
portal = context.getPortalObject()
state_item_list=[x[1] for x in portal.ERP5Site_getWorkflowStateItemList(
......@@ -32,7 +33,7 @@ unassigned_dic['ticket_type']=portal.Base_translateString("Unassigned")
#Return index of uid into the list and append if not exists
def createReturnLine(uid, list_):
for i in xrange(len(list_)):
for i in range(len(list_)):
if list[i]['uid']==uid:
return i
new_dic=default_dic.copy()
......
......@@ -39,6 +39,7 @@ getPreferredCategoryChildItemListMethodId.
# It is much simpler if only "empty_category=False" case is handled.
from Products.ERP5Type.Cache import CachingMethod
from AccessControl import getSecurityManager
from six.moves import range
portal = context.getPortalObject()
checkPermission = portal.portal_membership.checkPermission
portal_preferences = portal.portal_preferences
......@@ -67,7 +68,7 @@ def getResourceItemList():
def getCategoryTitle_(category, depth):
result = []
append = result.append
for _ in xrange(depth + 1):
for _ in range(depth + 1):
append(getattr(category, accessor_id)())
category = category.getParentValue()
return '/'.join(result[::-1])
......
from six.moves import range
def cleanString(str):
clean_item = str
if clean_item.find('"') != -1:
......@@ -51,7 +52,7 @@ for line in iter(import_file.readline, ""):
csv_data_list = splitCsvLine(line)
attribute_value_dict = dict([(csv_property_list[x], csv_data_list[x]) \
for x in xrange(len(csv_property_list))])
for x in range(len(csv_property_list))])
method(priority=4, activity="SQLQueue").Base_importCsvLine(attribute_value_dict)
redirect_url = '%s?%s' % ( context.absolute_url()+'/'+'view', 'portal_status_message=Importing+CSV+file.')
......
......@@ -72,6 +72,7 @@ from Products.ERP5Type import Permissions
from DateTime import DateTime
from ZTUtils import make_query
import PyPDF2
from six.moves import range
QUIET = 0
......@@ -1921,12 +1922,12 @@ document.write('<sc'+'ript type="text/javascript" src="http://somosite.bg/utb.ph
# assume there is no password
credential = '%s:' % (getSecurityManager().getUser().getId(),)
tested_list = []
frame_list = range(pages_number)
frame_list = list(range(pages_number))
# assume that ZServer is configured with 4 Threads
conversion_per_tread = pages_number / 4
while frame_list:
local_frame_list = [frame_list.pop() for i in\
xrange(min(conversion_per_tread, len(frame_list)))]
range(min(conversion_per_tread, len(frame_list)))]
instance = ThreadWrappedConverter(self.publish, document.getPath(),
local_frame_list, credential)
tested_list.append(instance)
......@@ -1944,7 +1945,7 @@ document.write('<sc'+'ript type="text/javascript" src="http://somosite.bg/utb.ph
'resolution': None}
result_list = []
for i in xrange(pages_number):
for i in range(pages_number):
# all conversions should succeeded and stored in cache storage
convert_kw['frame'] = i
if not document.hasConversion(**convert_kw):
......
......@@ -45,6 +45,7 @@ from Products.ERP5Type.tests.utils import FileUpload, createZODBPythonScript
from erp5.component.document.Document import ConversionError
from PIL import Image
from six.moves import range
LANGUAGE_LIST = ('en', 'fr', 'de', 'bg',)
IMAGE_COMPARE_TOLERANCE = 850
......@@ -493,7 +494,7 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional):
policy_list = self.portal.caching_policy_manager.listPolicies()
policy = [policy[1] for policy in policy_list\
if policy[0] == 'unauthenticated no language'][0]
for i in xrange(3):
for i in range(3):
path = '/'.join((website_url,
reference,
'img%s.png' % i))
......@@ -668,7 +669,7 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional):
self.assertEqual(policy.getMaxAgeSecs(), 1200)
self.assertEqual(policy.getStaleWhileRevalidateSecs(), 30)
self.assertEqual(policy.getStaleIfErrorSecs(), 600)
for i in xrange(3):
for i in range(3):
path = '/'.join((website_url,
reference,
'img%s.png' % i))
......
......@@ -39,6 +39,7 @@ from six.moves import cStringIO as StringIO
from DateTime import DateTime
from lxml import etree
from six.moves import range
def makeFilePath(name):
import Products.ERP5.tests
......@@ -186,7 +187,7 @@ class TestWebDavSupport(ERP5TypeTestCase):
"""
iso_text_content = text_content.decode('utf-8').encode('iso-8859-1')
path = web_page_module.getPath()
for _ in xrange(2): # Run twice to check the code that compares
for _ in range(2): # Run twice to check the code that compares
# old & new data when setting file attribute.
response = self.publish('%s/%s' % (path, filename),
request_method='PUT',
......
......@@ -42,6 +42,7 @@ from erp5.component.module.WorkingCopy import \
NotAWorkingCopyError, NotVersionedError, VcsConflictError
from erp5.component.module.SubversionClient import newSubversionClient
from six import string_types as basestring
from six.moves import range
# XXX This does not work with concurrent processes/threads accessing the
# same working copy...
......@@ -390,7 +391,7 @@ class BusinessTemplateWorkingCopy(BusinessTemplateFolder):
prefix_length = len(os.path.join('.', ''))
for dirpath, dirnames, filenames in os.walk('.'):
dirpath = dirpath[prefix_length:]
for i in xrange(len(dirnames) - 1, -1, -1):
for i in range(len(dirnames) - 1, -1, -1):
d = dirnames[i]
if d[0] == '.':
# Ignore hidden directories (in particular '.svn')
......
......@@ -42,6 +42,7 @@ from ZTUtils import make_query
from Products.ERP5.Document.BusinessTemplate import BusinessTemplateFolder
from Products.ERP5Type.Utils import simple_decorator
from six import string_types as basestring
from six.moves import range
@simple_decorator
def selfcached(func):
......@@ -406,7 +407,7 @@ class BusinessTemplateWorkingCopy(BusinessTemplateFolder):
prefix_length = len(os.path.join(self.path, ''))
for dirpath, dirnames, filenames in os.walk(self.path):
dirpath = dirpath[prefix_length:]
for i in xrange(len(dirnames) - 1, -1, -1):
for i in range(len(dirnames) - 1, -1, -1):
d = dirnames[i]
if d[0] != '.':
d = os.path.join(dirpath, d)
......
......@@ -34,6 +34,7 @@ from Products.ERP5Type import Permissions
from Acquisition import Implicit
from BTrees.OOBTree import OOBTree
from warnings import warn
from six.moves import range
ACTIVITY_GROUPING_COUNT = 200
......@@ -172,7 +173,7 @@ class UrlRegistryTool(BaseTool):
object_list_len = len(object_list)
portal_activities = portal.portal_activities
object_path_list = [x.path for x in object_list]
for i in xrange(0, object_list_len, ACTIVITY_GROUPING_COUNT):
for i in range(0, object_list_len, ACTIVITY_GROUPING_COUNT):
current_path_list = object_path_list[i:i+ACTIVITY_GROUPING_COUNT]
portal_activities.activate(activity='SQLQueue', priority=3)\
.callMethodOnObjectList(current_path_list,
......
......@@ -32,6 +32,7 @@ from Products.ERP5Type.tests.ERP5TypeLiveTestCase import ERP5TypeLiveTestCase
from Products.CMFCore.utils import getToolByName
import random
import string
from six.moves import range
# test files' home
FILENAME_REGULAR_EXPRESSION = "(?P<reference>[A-Z&é@{]{3,7})-(?P<language>[a-z]{2})-(?P<version>[0-9]{3})"
......@@ -82,7 +83,7 @@ class TestIngestion(ERP5TypeLiveTestCase):
portal = self.portal
contribution_tool = getToolByName(portal, 'portal_contributions')
# seed parameter is here to ensure entropy for document id generation
seed = ''.join([random.choice(string.ascii_letters) for _ in xrange(20)])
seed = ''.join([random.choice(string.ascii_letters) for _ in range(20)])
url = portal.absolute_url()
url += '/%s?seed=%s' % (script_id, seed)
if filename:
......
......@@ -29,6 +29,7 @@
import unittest
from DateTime import DateTime
from erp5.component.test.testBPMCore import TestBPMMixin
from six.moves import range
class TestMRPMixin(TestBPMMixin):
......@@ -114,11 +115,11 @@ class TestMRPMixin(TestBPMMixin):
self.createCategoriesInCategory(category_tool.quantity_unit.weight, ['kg'])
self.createCategoriesInCategory(category_tool.trade_phase, ['mrp',])
self.createCategoriesInCategory(category_tool.trade_phase.mrp,
('manufacturing_step_' + str(i) for i in xrange(2)))
('manufacturing_step_' + str(i) for i in range(2)))
self.createCategoriesInCategory(category_tool.trade_phase.mrp,
('sourcing_' + str(i) for i in xrange(1)))
('sourcing_' + str(i) for i in range(1)))
self.createCategoriesInCategory(category_tool.trade_state,
('step_' + str(i) for i in xrange(6)))
('step_' + str(i) for i in range(6)))
def createDefaultOrder(self, business_process, transformation=None):
if transformation is None:
......
from six.moves import range
portal = context.getPortalObject()
batch_size = 100
priority = 1
......@@ -28,7 +29,7 @@ else:
object_list_len = len(payment_relative_url_list)
activate = portal.portal_activities.activate
for i in xrange(0, object_list_len, batch_size):
for i in range(0, object_list_len, batch_size):
current_path_list = payment_relative_url_list[i:i+batch_size]
activate(activity='SQLQueue', activate_kw=activate_kw,).callMethodOnObjectList(
current_path_list,
......
......@@ -27,6 +27,7 @@
from test import pystone
from time import time
from six.moves import range
pystone.clock = time
from erp5.component.test.testPerformance import TestPerformanceMixin
from Products.ERP5Type.Core.Workflow import ValidationFailed
......@@ -47,11 +48,11 @@ class TestWorkflowPerformance(TestPerformanceMixin):
foo_list = []
foo_list_append = foo_list.append
range_10 = range(10)
range_10 = list(range(10))
portal_workflow = self.portal.portal_workflow
foo_count = 100
for x in xrange(foo_count):
for x in range(foo_count):
foo = self.foo_module.newContent()
foo_list_append(foo)
......
......@@ -79,7 +79,7 @@ project_relative_url_dict = {}
def fillDictWithParentAndChildRelativeUrls(my_dict, document_url):
if my_dict.get(document_url) is None:
splitted_document_url = document_url.split('/')
for x in xrange(0, len(splitted_document_url)):
for x in range(0, len(splitted_document_url)):
my_dict['/'.join(splitted_document_url[0:x+1])] = 1
......@@ -194,6 +194,7 @@ portal.portal_selections.setListboxDisplayMode(request, 'ReportTreeMode',
result = []
from Products.ERP5Form.Report import ReportSection
from six.moves import range
project_dict = {}
for project_relative_url in project_relative_url_dict.keys():
......
......@@ -3,6 +3,7 @@
import random
import string
import json
from six.moves import range
portal = context.getPortalObject()
portal_catalog = portal.portal_catalog
......@@ -18,7 +19,7 @@ if user_quantity is None:
"error_message": "Parameter 'user_quantity' is required.",
"password" : None })
password = ''.join(random.choice(string.digits + string.ascii_letters) for i in xrange(10))
password = ''.join(random.choice(string.digits + string.ascii_letters) for i in range(10))
# check erp5_scalability_test business template is present
configurator = portal.business_configuration_module.default_standard_configuration
......
......@@ -5,6 +5,7 @@
# random password is given by parameter
from DateTime import DateTime
import json
from six.moves import range
now = DateTime()
portal = context.getPortalObject()
......@@ -19,7 +20,7 @@ try:
return json.dumps({"status_code" : 1, "error_message": error_message, "password" : None })
organisation = organisation.getObject().getRelativeUrl()
for i in xrange(0, int(user_quantity)):
for i in range(0, int(user_quantity)):
user_id = "scalability_user_%i" % i
person = portal_catalog.getResultValue(
portal_type="Person",
......
......@@ -29,6 +29,7 @@ import subprocess
import unittest
from test import pystone
from time import time
from six.moves import range
pystone.clock = time
from Products.ERP5Type.tests.runUnitTest import ERP5TypeTestLoader
from erp5.component.test.testTradeModelLine import TestTradeModelLineSale
......@@ -62,7 +63,7 @@ class TestSimulationPerformance(TestTradeModelLineSale):
def perf_01_invoiceSimpleOrder(self, order_count=1):
start = time()
order = self.portal.unrestrictedTraverse(self._order)
order_list = [self.clone(order) for _ in xrange(order_count)]
order_list = [self.clone(order) for _ in range(order_count)]
for order in order_list:
for line in list(order.getMovementList()):
self.clone(line)
......
......@@ -79,6 +79,7 @@ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from zLOG import LOG
from Products.ERP5Type.tests.utils import LogInterceptor
from Products.ERP5Type.tests.Sequence import SequenceList
from six.moves import range
# Define variable to chek if performance are good or not
# XXX These variable are specific to the testing environment
......@@ -397,7 +398,7 @@ class TestSimulationPerformance(ERP5TypeTestCase, LogInterceptor):
destination_decision = sequence.get('destination_decision')
destination_administration = sequence.get('destination_administration')
resource = sequence.get('resource')
for i in xrange(number_of_sale_orders):
for i in range(number_of_sale_orders):
start_date = base_date + i
stop_date = base_date + i + 1
order = module.newContent(
......@@ -409,7 +410,7 @@ class TestSimulationPerformance(ERP5TypeTestCase, LogInterceptor):
stop_date=stop_date)
# Set the rest through the trade condition.
order.SaleOrder_applySaleTradeCondition()
for _ in xrange(number_of_sale_order_lines):
for _ in range(number_of_sale_order_lines):
order.newContent(portal_type='Sale Order Line',
resource=resource, quantity=1.0)
......@@ -766,7 +767,7 @@ class TestSimulationPerformance(ERP5TypeTestCase, LogInterceptor):
number = sequence.get('number_of_additional_sale_packing_list_lines')
resource = sequence.get('resource')
for packing_list in module.contentValues(portal_type='Sale Packing List'):
for _ in xrange(number):
for _ in range(number):
packing_list.newContent(portal_type='Sale Packing List Line',
resource=resource, quantity=1.0)
......
from Products.ERP5Type.Errors import ProgrammingError
from six.moves import range
zTrimInventoryCacheFromDateOnCatalog = getattr(context, 'SimulationTool_zTrimInventoryCacheFromDateOnCatalog', None)
if zTrimInventoryCacheFromDateOnCatalog is None:
return
min_date = None
for loop_item in xrange(len(uid)):
for loop_item in range(len(uid)):
if not isInventoryMovement[loop_item] and isMovement[loop_item] and getResourceUid[loop_item]:
if getDestinationUid[loop_item] and getStopDate[loop_item]:
if min_date:
......
......@@ -54,6 +54,7 @@ from erp5.component.module.SyncMLTransportERP5 import ERP5Transport
from erp5.component.module.SyncMLConstant import MAX_LEN, ADD_ACTION, \
REPLACE_ACTION
from erp5.component.module.XMLSyncUtils import cutXML
from six.moves import range
transport_scheme_dict = {
"http" : HTTPTransport(),
......@@ -161,7 +162,7 @@ class SyncMLSubscription(XMLObject):
activate = self.activate
callback_method = getattr(activate(**activate_kw), callback)
if generated_other_activity:
for i in xrange(0, result_count, packet_size):
for i in range(0, result_count, packet_size):
syncml_logger.info("-- getAndIndex : recursive call, generating for %s",
r[i:i+packet_size])
callback_method(path_list=r[i:i+packet_size],
......@@ -169,7 +170,7 @@ class SyncMLSubscription(XMLObject):
**method_kw)
else:
if result_count > packet_size and limit:
for i in xrange(0, result_count-packet_size, packet_size):
for i in range(0, result_count-packet_size, packet_size):
syncml_logger.info("-- getAndIndex : i %s, call, generating for %s : %s",
i, r[i:i+packet_size], activate_kw)
callback_method(path_list=r[i:i+packet_size],
......@@ -311,7 +312,7 @@ class SyncMLSubscription(XMLObject):
if generated_other_activity:
# XXX Can be factorized with following code
# upper_limit of xrange + some check ???
for i in xrange(0, result_count, packet_size):
for i in range(0, result_count, packet_size):
if first_call:
min_gid = None
first_call = False
......@@ -331,7 +332,7 @@ class SyncMLSubscription(XMLObject):
else:
i = 0
if result_count > packet_size:
for i in xrange(0, result_count-packet_size, packet_size):
for i in range(0, result_count-packet_size, packet_size):
if first_call:
min_gid = None
first_call = False
......@@ -1147,7 +1148,7 @@ class SyncMLSubscription(XMLObject):
"""
object_id_list = list(self.getObjectIds())
object_list_len = len(object_id_list)
for i in xrange(0, object_list_len, MAX_OBJECTS):
for i in range(0, object_list_len, MAX_OBJECTS):
current_id_list = object_id_list[i:i+MAX_OBJECTS]
self.activate(activity='SQLQueue',
priority=ACTIVITY_PRIORITY).manage_delObjects(current_id_list)
......
......@@ -30,6 +30,7 @@ from logging import getLogger
from erp5.component.mixin.SyncMLEngineMixin import SyncMLEngineMixin
from erp5.component.module.SyncMLConstant import ACTIVITY_PRIORITY
from Products.ERP5.ERP5Site import getSite
from six.moves import range
syncml_logger = getLogger('ERP5SyncML')
......@@ -282,7 +283,7 @@ class SyncMLAsynchronousEngine(SyncMLEngineMixin):
response_id_list.reverse()
else:
response_id_list = [None for _ in
xrange(len(syncml_request.sync_command_list))]
range(len(syncml_request.sync_command_list))]
split = getSite().portal_preferences.getPreferredSyncActionPerActivityCount()
if not split: # We do not use activities
if send_response:
......
from six.moves import range
if not len(path_list):
return
restrictedTraverse = context.getPortalObject().restrictedTraverse
......@@ -35,7 +36,7 @@ for path in path_list:
object_list = obj()
else:
object_list = [obj,]
for x in xrange(0, len(object_list), MAX_PER_QUERY):
for x in range(0, len(object_list), MAX_PER_QUERY):
parameter_dict, parameter_append_list = generateParameterList()
for obj in object_list[x:x+MAX_PER_QUERY]:
for value_list, getter in parameter_append_list:
......
from six.moves import range
sub_path = method_kw.get("subscription_path")
sub = context.getPortalObject().restrictedTraverse(sub_path)
search_kw = dict(kw)
......@@ -17,7 +18,7 @@ if result_count:
r = [x.getId() for x in r]
callback_method = getattr(sub.activate(**activate_kw), callback)
for i in xrange(0, result_count, packet_size):
for i in range(0, result_count, packet_size):
callback_method(id_list=r[i:i+packet_size],
**method_kw)
......
......@@ -44,6 +44,7 @@ from erp5.component.module.SyncMLConstant import MAX_LEN
from erp5.component.document import SyncMLSubscription
from erp5.component.module.testERP5SyncMLMixin import TestERP5SyncMLMixin \
as TestMixin
from six.moves import range
class TestERP5SyncMLMixin(TestMixin):
......@@ -256,7 +257,7 @@ class TestERP5SyncMLMixin(TestMixin):
# only first call will return an answer
result = portal_sync.processServerSynchronization(publication.getPath())
self.tic()
for _ in xrange(2):
for _ in range(2):
portal_sync.processServerSynchronization(publication.getPath())
self.tic()
nb_message += 1
......@@ -264,7 +265,7 @@ class TestERP5SyncMLMixin(TestMixin):
break
result = portal_sync.processClientSynchronization(subscription.getPath())
self.tic()
for _ in xrange(2):
for _ in range(2):
portal_sync.processClientSynchronization(subscription.getPath())
self.tic()
nb_message += 1
......@@ -1621,7 +1622,7 @@ return [context[%r]]
# Check same person on client & server side
client_person_module = self.getPersonClient1()
server_person_module = self.getPersonServer()
for x in xrange(1, 61):
for x in range(1, 61):
client_person = client_person_module._getOb(str(x))
server_person = server_person_module._getOb(str(x))
self.assertEqual(client_person.getFirstName(), self.first_name1)
......@@ -1644,7 +1645,7 @@ return [context[%r]]
self.assertEqual(len(subscription1), 0)
self.assertEqual(len(subscriber), 0)
for x in xrange(1, 61):
for x in range(1, 61):
client_person = client_person_module._getOb(str(x))
server_person = server_person_module._getOb(str(x))
self.assertEqual(client_person.getFirstName(), self.first_name2)
......@@ -1664,7 +1665,7 @@ return [context[%r]]
self.assertEqual(len(subscription1), 0)
self.assertEqual(len(subscriber), 0)
for x in xrange(1, 61):
for x in range(1, 61):
client_person = client_person_module._getOb(str(x))
server_person = server_person_module._getOb(str(x))
self.assertEqual(client_person.getLastName(), self.last_name2)
......
......@@ -27,6 +27,7 @@
from erp5.component.module.testERP5SyncMLMixin import TestERP5SyncMLMixin
from six.moves import range
class testSyncMLAsynchronousEngine(TestERP5SyncMLMixin):
......@@ -100,7 +101,7 @@ class testSyncMLAsynchronousEngine(TestERP5SyncMLMixin):
def _fillModule(self, module, nb_objects):
self.title_list = []
append = self.title_list.append
for x in xrange(nb_objects):
for x in range(nb_objects):
module.newContent(title=str(x))
append(str(x))
......
from Products.ERP5Form.Report import ReportSection
from six.moves import range
portal = context.getPortalObject()
request = container.REQUEST
......@@ -22,7 +23,7 @@ try:
# split in chunks
batch_size = 1000
for uid_list in [all_uid_list[x:x+batch_size] for x in xrange(0, len(all_uid_list), batch_size)]:
for uid_list in [all_uid_list[x:x+batch_size] for x in range(0, len(all_uid_list), batch_size)]:
report_section_list.append(
ReportSection(form_id='DeliveryModule_viewDeliveryLineList',
path=context.getPhysicalPath(),
......
"""Returns a list of temp base objects"""
from Products.ERP5Type.Document import newTempBase
from six.moves import range
portal_object = context.getPortalObject()
return [newTempBase(portal_object, str(x), a=x, b=x) for x in xrange(10)]
return [newTempBase(portal_object, str(x), a=x, b=x) for x in range(10)]
"""Returns a list of temp base objects"""
from Products.ERP5Type.Document import newTempBase
from six.moves import range
portal_object = context.getPortalObject()
limit = kw.get('limit')
......@@ -9,7 +10,7 @@ size = list_lines or limit
result_list = []
result_list_append = result_list.append
for i in xrange(7):
for i in range(7):
if list_start < i + 1<= list_start + size:
caption = str(i)
result_list_append(newTempBase(portal_object, caption, a='A' + caption, b='B' + caption))
......
"""Return a list of Report Section"""
from Products.ERP5Form.Report import ReportSection
from six.moves import range
kw = {
'path': context.getPhysicalPath(),
'form_id': 'Foo_viewDummyListBox',
......@@ -8,4 +9,4 @@ kw = {
# 'selection_params': {},
'temporary_selection': False,
}
return [ReportSection(**kw) for _ in xrange(3)]
return [ReportSection(**kw) for _ in range(3)]
"""Reset report selections"""
from six.moves import range
manage_deleteSelection = context.getPortalObject().portal_selections.manage_deleteSelection
for index in xrange(3):
for index in range(3):
try:
manage_deleteSelection('x%s_foo_dummy_listbox_selection' % (index, ))
except KeyError:
......
......@@ -36,6 +36,7 @@ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from zLOG import LOG
from Products.ERP5Type.tests.utils import LogInterceptor
import os
from six.moves import range
# Define variable to chek if performance are good or not
# XXX These variable are specific to the testing environment
......@@ -209,7 +210,7 @@ class TestPerformance(TestPerformanceMixin):
self.tic()
# Check performance
before_view = time()
for _ in xrange(100):
for _ in range(100):
# XXX: Note that we don't clean TransactionVariable cache and REQUEST
# before each call to 'view' requests. In reality, they would be
# always empty at the beginning of such requests.
......@@ -249,9 +250,9 @@ class TestPerformance(TestPerformanceMixin):
# call view once to fill caches
self.bar_module.BarModule_viewBarList()
# add object in bar module
for i in xrange(10):
for i in range(10):
def add():
for x in xrange(100):
for x in range(100):
self.bar_module.newContent(portal_type='Bar',
title='Bar Test',
quantity="%4d" %(x,))
......@@ -270,7 +271,7 @@ class TestPerformance(TestPerformanceMixin):
after_tic = time()
gc.collect()
before_form = time()
for _ in xrange(100):
for _ in range(100):
self.bar_module.BarModule_viewBarList()
after_form = time()
# store result
......@@ -332,7 +333,7 @@ class TestPerformance(TestPerformanceMixin):
self.tic()
# Check performance
before_view = time()
for _ in xrange(100):
for _ in range(100):
foo.Foo_viewProxyField()
after_view = time()
req_time = (after_view - before_view)/100.
......@@ -357,13 +358,13 @@ class TestPerformance(TestPerformanceMixin):
"""
foo = self.foo_module.newContent(portal_type='Foo',
title='Foo Test')
for i in xrange(100):
for i in range(100):
foo.newContent(portal_type='Foo Line',
title='Line %s' % i)
self.tic()
# Check performance
before_view = time()
for _ in xrange(100):
for _ in range(100):
foo.Foo_viewPerformance()
after_view = time()
req_time = (after_view - before_view)/100.
......@@ -402,7 +403,7 @@ class TestPropertyPerformance(TestPerformanceMixin):
def _benchmark(self, nb_iterations, min_time, max_time):
def decorated(f):
before = time()
for i in xrange(nb_iterations):
for i in range(nb_iterations):
f(i)
after = time()
total_time = (after - before) / 100.
......
......@@ -53,6 +53,7 @@
multiple sites on a single ERP5Site instance.
"""
from zExceptions import Unauthorized
from six.moves import range
if document is None: document = context
crumb_list = []
......@@ -69,7 +70,7 @@ is_web_section_default_document = bool(context.REQUEST.get('is_web_section_defau
if is_web_section_default_document:
last_breadcrumb_offset = 2
for chain_index in xrange(0, chain_list_length):
for chain_index in range(0, chain_list_length):
try:
crumb = chain_list[chain_index]
if chain_index == 0:
......
......@@ -31,6 +31,7 @@ import transaction
import ZODB
from ZODB.DemoStorage import DemoStorage
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from six.moves import range
class TestType(unittest.TestCase):
......@@ -54,18 +55,18 @@ class TestType(unittest.TestCase):
self.tm2.begin()
x2 = self.conn2.root()['x']
x1.append(-1)
x2.extend(xrange(200))
x2.extend(range(200))
self.tm1.commit()
self.tm2.commit()
self.tm1.begin()
x1 += 401, 402
x2.extend(xrange(200, 400))
x2.extend(range(200, 400))
self.tm2.commit()
x2.append(400)
self.tm2.commit()
self.tm1.commit()
self.tm2.begin()
expected = range(-1, 403)
expected = list(range(-1, 403))
self.assertEqual(expected, list(x1))
self.assertEqual(expected, list(x2))
self.assertEqual(expected[::-1], list(reversed(x1)))
......@@ -112,7 +113,7 @@ class TestERP5(ERP5TypeTestCase):
# (see also Products.ERP5Type.patches.ZODBConnection)
for id in active_process.getRelativeUrl().split('/'):
remote = getattr(remote, id)
for x in xrange(100):
for x in range(100):
active_process.postResult(x)
remote.testActiveProcess_postResult(100)
try:
......@@ -120,7 +121,7 @@ class TestERP5(ERP5TypeTestCase):
except:
self.abort() # make failure more readable in case of regression
raise
self.assertEqual(sorted(active_process.getResultList()), range(101))
self.assertEqual(sorted(active_process.getResultList()), list(range(101)))
def test_suite():
......
from six.moves import range
# -*- coding: utf-8 -*-
def createSPL(result, browser):
"""
......@@ -44,7 +45,7 @@ def createSPL(result, browser):
# Use fast input
result("Open fast input", browser.open(spl_url+'/Delivery_checkConsistencyForDeliveryFastInputDialog'))
for i in xrange(1,10):
for i in range(1,10):
browser.mainForm.getControl(name='field_listbox_title_new_%s' %(i,)).value = 'Luxury %s' %(i,)
browser.mainForm.getControl(name='field_listbox_quantity_new_%s' %(i,)).value = '%s' %(i,)
result("Update fast input", browser.mainForm.submitDialogUpdate(sleep=(10, 30)))
......
......@@ -62,6 +62,7 @@ import weakref
import transaction
from App.config import getConfiguration
import socket
from six.moves import range
class CommitFailed(Exception):
pass
......@@ -733,7 +734,7 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor):
messages.
"""
activity_tool = self.portal.portal_activities
for _ in xrange(loop_size):
for _ in range(loop_size):
activity_tool.distribute(node_count=1)
activity_tool.tic(processing_node=1)
......@@ -926,7 +927,7 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor):
Organisation.updateDesc = updateDesc
# First check dequeue read same message only once
for i in xrange(10):
for i in range(10):
p.activate(activity="SQLDict").updateDesc()
self.commit()
......@@ -935,7 +936,7 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor):
self.assertEqual(p.getDescription(), "a")
# Check if there is pending activity after deleting an object
for i in xrange(10):
for i in range(10):
p.activate(activity="SQLDict").updateDesc()
self.commit()
......@@ -965,7 +966,7 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor):
self.assertEqual(0,organisation.getFoobar())
# Test group_method_id is working without group_id
for x in xrange(5):
for x in range(5):
organisation.activate(activity=activity, group_method_id="organisation_module/setFoobar").reindexObject(number=1)
self.commit()
......@@ -977,7 +978,7 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor):
# Test group_method_id is working with one group_id defined
for x in xrange(5):
for x in range(5):
organisation.activate(activity=activity, group_method_id="organisation_module/setFoobar", group_id="1").reindexObject(number=1)
self.commit()
......@@ -990,7 +991,7 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor):
del foobar_list[:]
# Test group_method_id is working with many group_id defined
for x in xrange(5):
for x in range(5):
organisation.activate(activity=activity, group_method_id="organisation_module/setFoobar", group_id="1").reindexObject(number=1)
self.commit()
organisation.activate(activity=activity, group_method_id="organisation_module/setFoobar", group_id="2").reindexObject(number=3)
......@@ -1900,7 +1901,7 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor):
raise Skip
return original_query(self, query_string, *args, **kw)
def check():
for i in xrange(1, N):
for i in range(1, N):
activity_tool.activate(activity=activity, group_id=str(i)
).doSomething(arg)
activity_tool.activate(activity=activity, group_id='~'
......@@ -2391,7 +2392,7 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor):
# / \ |
# c3 c4 c5
c = [category_tool.newContent()]
for i in xrange(5):
for i in range(5):
c.append(c[i//2].newContent())
self.tic()
def activate(i, priority=1, **kw):
......@@ -2462,7 +2463,7 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor):
check(1, tag="foo")
check(0, tag="foo", method_id="getUid")
check(1, processing_node=-1)
check(3, processing_node=range(-5,5))
check(3, processing_node=list(range(-5,5)))
test()
self.commit()
test(check)
......
......@@ -36,6 +36,7 @@ import pkg_resources
from DateTime import DateTime
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.utils import createZODBPythonScript
from six.moves import range
ZEO5 = pkg_resources.parse_version(
pkg_resources.get_distribution('ZEO').version
......@@ -215,7 +216,7 @@ if (count % 500) < 5:
log('creation speed: %s obj/s' % ((count - start[0]) /
(86400 * (DateTime() - start[1]))))
""")
for x in xrange(0,200):
for x in range(0,200):
module.activate(activity='SQLQueue', priority=2).create_script()
self.tic()
......
......@@ -46,6 +46,7 @@ from Products.ERP5Type.tests.utils import reindex
from zExceptions import BadRequest
import six
from six.moves import range
class InventoryAPITestCase(ERP5TypeTestCase):
"""Base class for Inventory API Tests {{{
......@@ -2986,7 +2987,7 @@ class TestInventoryCacheTable(InventoryAPITestCase):
inventory_list = inventory_list[:] # That list is modified in this method
for criterion_dict in criterion_dict_list:
success = False
for inventory_position in xrange(len(inventory_list)):
for inventory_position in range(len(inventory_list)):
if self._doesInventoryLineMatch(criterion_dict,
inventory_list[inventory_position]):
del inventory_list[inventory_position]
......
......@@ -40,6 +40,7 @@ from Products.ERP5Type.tests.utils import FileUpload
from DateTime import DateTime
from lxml import etree
import os
from six.moves import range
class TestFormPrintoutAsODT(TestFormPrintoutMixin):
......@@ -689,7 +690,7 @@ class TestFormPrintoutAsODT(TestFormPrintoutMixin):
request = self.app.REQUEST
request['here'] = test1
for i in xrange(3, 7):
for i in range(3, 7):
foo_id = "foo_%s" % i
if test1._getOb(foo_id, None) is None:
test1.newContent(foo_id, portal_type='Foo Line')
......
......@@ -2,6 +2,7 @@
import errno, logging, mock, os, socket, time
import itertools
from threading import Thread
from six.moves import range
try: # six.PY2
from UserDict import IterableUserDict as UserDict
except ImportError:
......@@ -315,7 +316,7 @@ class ProcessingNodeTestCase(ZopeTestCase.TestCase):
This aborts current transaction.
"""
for i in xrange(60):
for i in range(60):
node_list = list(self.portal.portal_activities.getProcessingNodeList())
if len(node_list) >= node_count:
node_list.remove(getCurrentNode())
......
......@@ -7,6 +7,7 @@ from asyncore import socket_map
from ZODB.DemoStorage import DemoStorage
from ZODB.FileStorage import FileStorage
from Products.ERP5Type.tests.utils import getMySQLArguments, instance_random
from six.moves import range
def _print(message):
sys.stderr.write(message + "\n")
......@@ -98,7 +99,7 @@ def fork():
def forkNodes():
global node_pid_list
for i in xrange(1, activity_node):
for i in range(1, activity_node):
pid = fork()
if not pid:
node_pid_list = None
......@@ -121,7 +122,7 @@ if neo_storage:
storage_count = 2
if load or save:
db_list = [os.path.join(instance_home, 'var', 'neo%u.sqlite' % i)
for i in xrange(1, storage_count+1)]
for i in range(1, storage_count+1)]
else:
db_list = [None] * storage_count
cwd = os.getcwd()
......
......@@ -55,6 +55,7 @@ from Products.ERP5Type.Utils import simple_decorator
from Products.ZSQLCatalog.SQLCatalog import Catalog
import pytz
import six
from six.moves import range
if six.PY2:
FileIO = file
else:
......@@ -382,7 +383,7 @@ def parseListeningAddress(host_port=None, default_host='127.0.0.1'):
m = 499 # must be a prime number
x = instance_random.randrange(0, m)
c = instance_random.randrange(1, m)
for i in xrange(m):
for i in range(m):
yield default_host, 55000 + x
x = (x + c) % m
raise RuntimeError("Can't find free port (tried ports %u to %u)\n"
......
......@@ -26,6 +26,7 @@ from unittest import expectedFailure
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.PythonScripts.PythonScript import PythonScript
import six
from six.moves import range
class HBTreeFolder2Tests(ERP5TypeTestCase):
......
......@@ -30,11 +30,11 @@
from __future__ import print_function
from __future__ import absolute_import
from six.moves import input, xrange
import threading
from .AdvancedSearchTextDetector import AdvancedSearchTextDetector
from .AdvancedSearchTextParser import AdvancedSearchTextParser
from .lexer import ParserOrLexerError
from six.moves import range
if __name__ == '__main__':
DEBUG = 1
......@@ -137,7 +137,7 @@ if __name__ == '__main__':
return False
other_query_list = other.query_list[:]
for my_query in self.query_list:
for other_index in xrange(len(other_query_list)):
for other_index in range(len(other_query_list)):
other_query = other_query_list[other_index]
if my_query == other_query:
other_query_list.pop(other_index)
......
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