Commit daffb775 authored by Julien Muchembled's avatar Julien Muchembled

style: use new syntax (from Python 2.7) for set comprehensions

parent 742d237c
......@@ -272,7 +272,7 @@ class AppliedRule(XMLObject, ExplainableMixin):
break
if root_rule:
self._setSpecialise(root_rule)
delivery_set = set((delivery,))
delivery_set = {delivery}
def updateMovementCollection(rule, context, *args, **kw):
orig_updateMovementCollection(rule, context, *args, **kw)
new_parent = context.getParentValue()
......
......@@ -136,8 +136,7 @@ class BusinessProcess(Path, XMLObject):
if trade_phase is not None:
if isinstance(trade_phase, basestring):
trade_phase = (trade_phase,)
trade_phase = set(x.split('trade_phase/', 1)[-1]
for x in trade_phase)
trade_phase = {x.split('trade_phase/', 1)[-1] for x in trade_phase}
kw.setdefault('portal_type', self.getPortalTradeModelPathTypeList())
kw.setdefault('sort_on', 'int_index')
original_path_list = self.objectValues(**kw) # Why Object Values ??? XXX-JPS
......
......@@ -558,9 +558,9 @@ class BaseTemplateItem(Implicit, Persistent):
klass = obj.__class__
classname = klass.__name__
attr_set = set(('_dav_writelocks', '_filepath', '_owner', '_related_index',
'last_id', 'uid',
'__ac_local_roles__', '__ac_local_roles_group_id_dict__'))
attr_set = {'_dav_writelocks', '_filepath', '_owner', '_related_index',
'last_id', 'uid',
'__ac_local_roles__', '__ac_local_roles_group_id_dict__'}
if export:
if keep_workflow_history_last_history_only:
self._removeAllButLastWorkflowHistory(obj)
......@@ -2002,14 +2002,12 @@ class WorkflowTemplateItem(ObjectTemplateItem):
context.getTemplatePortalTypeWorkflowChainList()]
chain_dict = getChainByType(context)[1]
for workflow_id in removed_workflow_id_list:
affected_portal_type_set = set([x[0][6:] for x in \
chain_dict.iteritems() \
if workflow_id in \
[y.strip() for y in x[1].split(',')]])
safe_portal_type_set = set([x[0] for x in installed_chain_list \
if x[1] == workflow_id]) - \
set([x[0] for x in new_chain_list \
if x[1] == workflow_id])
affected_portal_type_set = {x[6:] for x, y in chain_dict.iteritems()
if any(workflow_id == y.strip() for y in y.split(','))}
safe_portal_type_set = {x for x, y in installed_chain_list
if y == workflow_id}
safe_portal_type_set.difference_update(x for x, y in new_chain_list
if y == workflow_id)
if affected_portal_type_set - safe_portal_type_set:
value = modified_workflow_dict['portal_workflow/%s' % workflow_id]
modified_workflow_dict['portal_workflow/%s' % workflow_id] = \
......@@ -2057,10 +2055,10 @@ class WorkflowTemplateItem(ObjectTemplateItem):
object_keys = [object_path]
else:
object_keys = self._archive.keys()
removed_workflow_id_list = set([x.split('/', 1)[1] for x in object_keys])
removed_workflow_id_list = {x.split('/', 1)[1] for x in object_keys}
(default_chain, chain_dict) = getChainByType(context)
for portal_type, workflow_ids in chain_dict.iteritems():
workflow_ids = set([x.strip() for x in workflow_ids.split(',')]) - \
workflow_ids = {x.strip() for x in workflow_ids.split(',')} - \
removed_workflow_id_list
chain_dict[portal_type] = ', '.join(workflow_ids)
context.portal_workflow.manage_changeWorkflows(default_chain,
......@@ -2510,7 +2508,7 @@ class PortalTypeAllowedContentTypeTemplateItem(BaseTemplateItem):
self.business_template_class_property)._objects
else:
old_objects = {}
for key in set(self._objects.keys()).union(set(old_objects.keys())):
for key in set(self._objects.keys()).union(old_objects.keys()):
if key in update_dict or force:
if not force:
action = update_dict[key]
......
......@@ -84,9 +84,9 @@ class CategoryBudgetVariation(BudgetVariation):
item_list = self.getBudgetLineVariationRangeCategoryList(budget_line)
if matrixbox:
used_node_item_set = set([item[0] for item in cell_range[0]])
used_node_item_set = {item[0] for item in cell_range[0]}
else:
used_node_item_set = set([item for item in cell_range[0]])
used_node_item_set = {item for item in cell_range[0]}
if engaged_budget:
consumption_dict = budget_line.getConsumedBudgetDict()
......
......@@ -224,7 +224,7 @@ class Delivery(XMLObject, ImmobilisationDelivery, SimulableMixin,
if movement_list:
if isinstance(portal_type, str):
portal_type = set((portal_type,))
portal_type = portal_type,
elif isinstance(portal_type, (list, tuple)):
portal_type = set(portal_type)
......
......@@ -119,9 +119,9 @@ class NodeBudgetVariation(BudgetVariation):
self._getNodeTitle(node))
for node in self._getNodeList(budget_line)]
if matrixbox:
used_node_item_set = set([item[0] for item in cell_range[0]])
used_node_item_set = {item[0] for item in cell_range[0]}
else:
used_node_item_set = set([item for item in cell_range[0]])
used_node_item_set = {item for item in cell_range[0]}
if engaged_budget:
consumption_dict = budget_line.getConsumedBudgetDict()
......
......@@ -135,7 +135,7 @@ class SQLNonContinuousIncreasingIdGenerator(IdGenerator):
id_group_done.append(id_group)
# save the last ids which not exist in sql
for id_group in (set(self.last_max_id_dict.keys()) - set(id_group_done)):
for id_group in set(self.last_max_id_dict).difference(id_group_done):
set_last_id_method(id_group=id_group,
last_id=self.last_max_id_dict[id_group].value)
......
......@@ -78,8 +78,8 @@ class TradeModelSolver(AcceptSolver):
# related lines.
# XXX is there any better way than using rule's reference?
trade_model_related_movement_dict = {}
for delivery in set(movement.getRootDeliveryValue()
for movement in delivery_dict):
for delivery in {movement.getRootDeliveryValue()
for movement in delivery_dict}:
for movement in delivery.getMovementList():
movement_list = delivery_dict.get(movement)
# hard coded reference name
......
......@@ -1801,10 +1801,10 @@ class ERP5Generator(PortalGenerator):
container_path = root[prefix_len:]
load = traverse(container_path)._importObjectFromFile
if container_path:
id_set = set(x[:-4] for x in files if x[-4:] == '.xml')
id_set = {x[:-4] for x in files if x[-4:] == '.xml'}
else:
id_set = set(quote(x) for x in content_id_list
if not context.hasObject(x))
id_set = {quote(x) for x in content_id_list
if not context.hasObject(x)}
dirs[:] = id_set.intersection(dirs)
for file in id_set:
load(os.path.join(root, file + '.xml'),
......
......@@ -120,10 +120,8 @@ def _getPropertyList(document, acquire=True):
return property_dict
def _getCategoryList(document, acquire=True):
bad_category_list = ['solver', ]
# we care already stored category only
document_category_set = set([x.split('/',1)[0] for x in \
document.getCategoryList()])
document_category_set = {x.split('/',1)[0]
for x in document.getCategoryList()}
getPropertyList = document.getPropertyList
return dict([(x, getPropertyList(x)) for x in document_category_set \
if x not in bad_category_list])
return {x: getPropertyList(x) for x in document_category_set if x != 'solver'}
......@@ -341,7 +341,7 @@ class FakeMovement:
Be careful: behaviour differs from CMFCategory in that returned
list may include None, when there is at least 1 unlinked SM.
"""
return list(set(x.getDelivery() for x in self.__movement_list))
return list({x.getDelivery() for x in self.__movement_list})
def getDeliveryValue(self):
"""
......
......@@ -511,8 +511,7 @@ class ContributionTool(BaseTool):
if depth < 0:
# Do nothing if crawling depth is reached
return
url_list = content.getContentNormalisedURLList()
for url in set(url_list):
for url in set(content.getContentNormalisedURLList()):
# LOG('trying to crawl', 0, url)
# Some url protocols should not be crawled
if urlparse.urlsplit(url)[0] in no_crawl_protocol_list:
......
......@@ -220,8 +220,8 @@ class TaskDistributionTool(BaseTool):
if test_result.getSimulationState() == 'started':
if line.getSimulationState() == "started":
line.stop(**status_dict)
if set([x.getSimulationState() for x in test_result.objectValues(
portal_type="Test Result Line")]) == set(["stopped"]):
if {"stopped"} == {x.getSimulationState()
for x in test_result.objectValues(portal_type="Test Result Line")}:
test_result.stop()
def _extractXMLRPCDict(self, xmlrpc_dict):
......
......@@ -1114,7 +1114,7 @@ class TemplateTool (BaseTool):
template_title_list = set(template_title_list)
installed_bt5_title_list = self.getInstalledBusinessTemplateTitleList()
bt5_set = set([])
bt5_set = set()
for available_bt5 in available_bt5_list:
if available_bt5.title in template_title_list:
template_title_list.remove(available_bt5.title)
......
......@@ -229,8 +229,8 @@ class BaseAmountResolver(BaseAmountDict):
variated_base_amount = base_amount, variation_category_list
resolving = self._resolving
if variated_base_amount not in self._dict:
self._resolving = self._dict[variated_base_amount] = set(
(variated_base_amount,))
self._resolving = self._dict[variated_base_amount] = \
{variated_base_amount}
self._getGeneratedAmountQuantity(base_amount, variation_category_list)
self._resolving = resolving
resolving |= self._dict[variated_base_amount]
......
......@@ -2016,9 +2016,9 @@ class TestAccountingReports(AccountingTestCase, ERP5ReportTestCase):
data_line_list = [l for l in line_list if l.isDataLine()]
self.assertEqual(2, len(data_line_list))
self.assertEqual(
set([line.getColumnProperty('Movement_getSpecificReference') for line in
data_line_list]),
set(('Source Reference', 'Destination Reference')))
{line.getColumnProperty('Movement_getSpecificReference')
for line in data_line_list},
{'Source Reference', 'Destination Reference'})
for line in data_line_list:
if line.getColumnProperty('Movement_getSpecificReference')\
......
......@@ -6623,9 +6623,9 @@ class TestBusinessTemplate(BusinessTemplateMixin):
new_object.__ac_local_roles__ = dict(group=['Assignee', 'Assignor'],
another_group=['Assignee'])
initial___ac_local_roles_group_id_dict__ = dict(
Alternate=set([('group', 'Assignee')]),
Another=set([('group', 'Assignor'),
('another_group', 'Assignee')])).copy()
Alternate={('group', 'Assignee')},
Another={('group', 'Assignor'),
('another_group', 'Assignee')})
new_object.__ac_local_roles_group_id_dict__ = initial___ac_local_roles_group_id_dict__
self.tic()
......
......@@ -1073,13 +1073,12 @@ class TestERP5Base(ERP5TypeTestCase):
# patch the method, we'll abort later
self.portal.Localizer.get_selected_language = lambda: lang
self.assertEqual(set([person_1, person_2]),
set([x.getObject() for x in
self.portal.portal_catalog(translated_portal_type='Personne')]))
self.assertEqual(set([person_2, organisation]),
set([x.getObject() for x in
self.portal.portal_catalog(translated_validation_state_title='Brouillon',
portal_type=('Person', 'Organisation'))]))
self.assertEqual({person_1, person_2}, {x.getObject()
for x in self.portal.portal_catalog(translated_portal_type='Personne')})
self.assertEqual({person_2, organisation}, {x.getObject()
for x in self.portal.portal_catalog(
translated_validation_state_title='Brouillon',
portal_type=('Person', 'Organisation'))})
self.assertEqual([person_2],
[x.getObject() for x in
self.portal.portal_catalog(translated_validation_state_title='Brouillon',
......
......@@ -2383,10 +2383,10 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
try:
self.assertEqual(len(expected_history), len(actual_history))
for expected, actual in zip(expected_history, actual_history):
shared_keys = set(expected.keys()) & set(actual.keys())
self.assertEqual(len(shared_keys), len(expected.keys()))
shared_keys = set(expected) & set(actual)
self.assertEqual(len(shared_keys), len(expected))
shared_item = set(expected.items()) & set(actual.items())
self.assertEqual(len(shared_item), len(expected.keys()))
self.assertEqual(len(shared_item), len(expected))
except AssertionError:
msg = 'History differs between expected:\n%s\nand real:\n%s'\
% (repr(expected_history), repr(actual_history))
......
......@@ -1094,7 +1094,7 @@ class TestInvoiceMixin(TestPackingListMixin):
# for each movement, we want to make sure that each rule is not
# instanciated more than once
if len(found_rule_dict):
self.assertEqual(set(found_rule_dict.itervalues()), set([1]))
self.assertEqual(set(found_rule_dict.itervalues()), {1})
elif k == 'parent_movement_type_list':
if rule.getParentValue().getDeliveryValue() is not None:
parent_type = rule.getParentValue().getDeliveryValue().getPortalType()
......
......@@ -569,8 +569,8 @@ class TestPredicates(TestPredicateMixIn):
# check that if we define the same filter than on predicate we get same result
self.assertEqual(len(predicate.searchResults()), 2)
self.assertSameSet(set([x.getObject() for x in predicate.searchResults(portal_type=['Person',
'Organisation'])]), set([fabien, nexedi]))
self.assertEqual({fabien, nexedi}, {x.getObject()
for x in predicate.searchResults(portal_type=('Person', 'Organisation'))})
# check that it's possible to filter results
self.assertEqual([x.getObject() for x in \
......@@ -583,8 +583,8 @@ class TestPredicates(TestPredicateMixIn):
currency_module = self.portal.getDefaultModule('Currency')
euro = currency_module.newContent(title='euro')
self.assertSameSet(set([x.getObject() for x in predicate.searchResults(portal_type=['Person',
'Organisation'])]), set([fabien, nexedi]))
self.assertEqual({fabien, nexedi}, {x.getObject()
for x in predicate.searchResults(portal_type=('Person', 'Organisation'))})
def test_TalesExpression(self):
# Predicates can test that a document is member of a category
......
......@@ -476,9 +476,9 @@ class TestSimulationPerformance(ERP5TypeTestCase, LogInterceptor):
'Simulation Movement')
self.assertEqual(simulation_movement.getQuantity(), 1.0)
self.assertEqual(simulation_movement.getResource(), resource)
self.assertEqual(set(simulation_movement.getCausalityList()), set((
self.assertEqual(set(simulation_movement.getCausalityList()), {
'business_process_module/test_bp/order_path',
'business_process_module/test_bp/order')))
'business_process_module/test_bp/order'})
self.assertEqual(simulation_movement.getDestinationDecision(),
destination_decision)
self.assertEqual(simulation_movement.getDestinationAdministration(),
......@@ -512,9 +512,9 @@ class TestSimulationPerformance(ERP5TypeTestCase, LogInterceptor):
for simulation_movement in simulation_movement_list:
self.assertEqual(simulation_movement.getPortalType(),
'Simulation Movement')
self.assertEqual(set(simulation_movement.getCausalityList()), set((
self.assertEqual(set(simulation_movement.getCausalityList()),{
'business_process_module/test_bp/deliver_path',
'business_process_module/test_bp/deliver')))
'business_process_module/test_bp/deliver'})
def stepCheckBuiltSaleInvoices(self, sequence=None, sequence_list=None,
**kw):
......@@ -547,9 +547,9 @@ class TestSimulationPerformance(ERP5TypeTestCase, LogInterceptor):
for simulation_movement in simulation_movement_list:
self.assertEqual(simulation_movement.getPortalType(),
'Simulation Movement')
self.assertEqual(set(simulation_movement.getCausalityList()), set((
self.assertEqual(set(simulation_movement.getCausalityList()), {
'business_process_module/test_bp/invoice_path',
'business_process_module/test_bp/invoice')))
'business_process_module/test_bp/invoice'})
tax_invoice_line = invoice_line_list[1]
self.assertEqual(tax_invoice_line.getResource(),
......@@ -568,10 +568,10 @@ class TestSimulationPerformance(ERP5TypeTestCase, LogInterceptor):
for simulation_movement in simulation_movement_list:
self.assertEqual(simulation_movement.getPortalType(),
'Simulation Movement')
self.assertEqual(set(simulation_movement.getCausalityList()), set((
self.assertEqual(set(simulation_movement.getCausalityList()), {
'business_process_module/test_bp/invoice_path',
'business_process_module/test_bp/invoice',
'sale_trade_condition_module/test_stc/vat_low')))
'sale_trade_condition_module/test_stc/vat_low'})
def stepCheckAddedSaleInvoices(self, sequence=None, sequence_list=None,
**kw):
......@@ -604,9 +604,9 @@ class TestSimulationPerformance(ERP5TypeTestCase, LogInterceptor):
for simulation_movement in simulation_movement_list:
self.assertEqual(simulation_movement.getPortalType(),
'Simulation Movement')
self.assertEqual(set(simulation_movement.getCausalityList()), set((
self.assertEqual(set(simulation_movement.getCausalityList()), {
'business_process_module/test_bp/invoice_path',
'business_process_module/test_bp/invoice')))
'business_process_module/test_bp/invoice'})
luxury_invoice_line = invoice_line_list[1]
self.assertEqual(luxury_invoice_line.getResource(),
......@@ -622,9 +622,9 @@ class TestSimulationPerformance(ERP5TypeTestCase, LogInterceptor):
for simulation_movement in simulation_movement_list:
self.assertEqual(simulation_movement.getPortalType(),
'Simulation Movement')
self.assertEqual(set(simulation_movement.getCausalityList()), set((
self.assertEqual(set(simulation_movement.getCausalityList()), {
'business_process_module/test_bp/invoice_path',
'business_process_module/test_bp/invoice')))
'business_process_module/test_bp/invoice'})
high_tax_invoice_line = invoice_line_list[2]
self.assertEqual(high_tax_invoice_line.getResource(),
......@@ -641,10 +641,10 @@ class TestSimulationPerformance(ERP5TypeTestCase, LogInterceptor):
for simulation_movement in simulation_movement_list:
self.assertEqual(simulation_movement.getPortalType(),
'Simulation Movement')
self.assertEqual(set(simulation_movement.getCausalityList()), set((
self.assertEqual(set(simulation_movement.getCausalityList()), {
'business_process_module/test_bp/invoice_path',
'business_process_module/test_bp/invoice',
'sale_trade_condition_module/test_stc/vat_high')))
'sale_trade_condition_module/test_stc/vat_high'})
low_tax_invoice_line = invoice_line_list[3]
self.assertEqual(low_tax_invoice_line.getResource(),
......@@ -663,10 +663,10 @@ class TestSimulationPerformance(ERP5TypeTestCase, LogInterceptor):
for simulation_movement in simulation_movement_list:
self.assertEqual(simulation_movement.getPortalType(),
'Simulation Movement')
self.assertEqual(set(simulation_movement.getCausalityList()), set((
self.assertEqual(set(simulation_movement.getCausalityList()), {
'business_process_module/test_bp/invoice_path',
'business_process_module/test_bp/invoice',
'sale_trade_condition_module/test_stc/vat_low')))
'sale_trade_condition_module/test_stc/vat_low'})
def stepCheckConvergedSalePackingLists(self, sequence=None,
sequence_list=None, **kw):
......@@ -713,9 +713,9 @@ class TestSimulationPerformance(ERP5TypeTestCase, LogInterceptor):
delivery.getQuantity())
self.assertEqual(simulation_movement.getResource(),
delivery.getResource())
self.assertEqual(set(simulation_movement.getCausalityList()), set((
self.assertEqual(set(simulation_movement.getCausalityList()), {
'business_process_module/test_bp/deliver_path',
'business_process_module/test_bp/deliver')))
'business_process_module/test_bp/deliver'})
self.assertEqual(simulation_movement.getDestinationDecision(),
destination_decision)
self.assertEqual(simulation_movement.getDestinationAdministration(),
......
......@@ -175,10 +175,8 @@ class TestTransformation(TestTransformationMixin, BaseTestUnitConversion):
transformation.setResourceValue(swimcap)
self.tic()
self.assertSameSet(
set(swimcap.getVariationCategoryList()),
set(transformation.getVariationCategoryList()),
)
self.assertSameSet(swimcap.getVariationCategoryList(),
transformation.getVariationCategoryList())
def test_variationCategoryWithIndividualVariation(self):
'''Check that individual variation are return when getVariationCategoryList
......
......@@ -135,10 +135,10 @@ class TestWorkflowStateTitleTranslation(ERP5TypeTestCase):
translated_state_title = self.getTranslation(msgid)
if translated_state_title is not None:
if translation_dict.has_key(translated_state_title):
try:
translation_dict[translated_state_title].add(state_id)
else:
translation_dict[translated_state_title] = set([state_id])
except KeyError:
translation_dict[translated_state_title] = {state_id}
for key, value in translation_dict.items():
......@@ -460,14 +460,12 @@ class TestTranslation(ERP5TypeTestCase):
portal_type='Organisation')
self.tic()
self.assertEqual(set([person_1, person_2]),
set([x.getObject() for x in
self.portal.portal_catalog(translated_portal_type='Personne')]))
self.assertEqual({person_1, person_2}, {x.getObject() for x in
self.portal.portal_catalog(translated_portal_type='Personne')})
self.assertEqual(set([person_2, organisation]),
set([x.getObject() for x in
self.assertEqual({person_2, organisation}, {x.getObject() for x in
self.portal.portal_catalog(translated_validation_state_title='Brouillon',
portal_type=('Person', 'Organisation'))]))
portal_type=('Person', 'Organisation'))})
self.assertEqual([person_2],
[x.getObject() for x in
self.portal.portal_catalog(translated_validation_state_title='Brouillon',
......
......@@ -408,7 +408,7 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
self.assertEqual(0, message_count)
# Check if all objects are catalogued as before
new_path_list = self.getSQLPathList()
self.assertEqual(set(original_path_list) - set(new_path_list), set())
self.assertTrue(set(original_path_list).issubset(new_path_list))
def test_14_ReindexWithBrokenCategory(self):
"""Reindexing an object with 1 broken category must not affect other valid
......@@ -1046,10 +1046,9 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
for k, v in query_dict.items():
setattr(query_record, k, v)
self.assertEqual(set([org_b.getPath(), org_c.getPath()]),
set([x.path for x in self.getCatalogTool()(
portal_type='Organisation',
title=query_record)]))
self.assertEqual({org_b.getPath(), org_c.getPath()},
{x.path for x in self.getCatalogTool()(portal_type='Organisation',
title=query_record)})
def test_39_DeferredConnection(self):
"""ERP5Catalog uses a deferred connection for full text indexing.
......@@ -1329,7 +1328,7 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
self.tic()
original_path_list = self.getSQLPathList(self.original_connection_id)
new_path_list = self.getSQLPathList(self.new_connection_id)
self.assertEqual(set(original_path_list) - set(new_path_list), set())
self.assertTrue(set(original_path_list).issubset(new_path_list))
self.organisation2 = module.newContent(portal_type='Organisation',
title="GreatTitle2")
first_deleted_url = self.organisation2.getRelativeUrl()
......@@ -2107,9 +2106,9 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
# future, in this case, this test have to be updated)
self.assertSameSet([doc], [x.getObject() for x in
ctool(portal_type='Organisation', description='Foo')])
self.assertEqual(set([doc, other_doc]), set([x.getObject() for x in
self.assertEqual({doc, other_doc}, {x.getObject() for x in
ctool(portal_type='Organisation', description=dict(query='Foo',
key='Keyword'))]))
key='Keyword'))})
def test_ignore_empty_string(self):
......@@ -2119,13 +2118,13 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
ctool = self.getCatalogTool()
def searchResults(**kw):
kw['portal_type'] = 'Organisation'
return set([x.getObject() for x in ctool.searchResults(**kw)])
return {x.getObject() for x in ctool.searchResults(**kw)}
# description='' is ignored
self.assertEqual(set([doc_with_empty_description, doc_with_description]),
self.assertEqual({doc_with_empty_description, doc_with_description},
searchResults(description=''))
# unless we exlicitly say we don't want to ignore empty strings
self.assertEqual(set([doc_with_empty_description]),
self.assertEqual({doc_with_empty_description},
searchResults(ignore_empty_string=0, description=''))
def test_ignore_empty_string_related_key(self):
......@@ -2138,11 +2137,11 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
ctool = self.getCatalogTool()
def searchResults(**kw):
kw['portal_type'] = 'Organisation'
return set([x.getObject() for x in ctool.searchResults(**kw)])
return {x.getObject() for x in ctool.searchResults(**kw)}
self.assertEqual(set([doc_with_empty_region_description, doc_without_region]),
self.assertEqual({doc_with_empty_region_description, doc_without_region},
searchResults(region_description=''))
self.assertEqual(set([doc_with_empty_region_description]),
self.assertEqual({doc_with_empty_region_description},
searchResults(ignore_empty_string=0, region_description=''))
def test_complex_query(self):
......
......@@ -186,7 +186,7 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
standard_bt5_config_save = business_configuration['1']
self.assertEqual(
set(self.standard_bt5_list),
set([x.bt5_id for x in standard_bt5_config_save.contentValues()]))
{x.bt5_id for x in standard_bt5_config_save.contentValues()})
# third one: we create a business template to store customer configuration
custom_bt5_config_save = business_configuration['2']
......
......@@ -795,11 +795,11 @@ class ERP5Form(Base, ZMIForm, ZopePageTemplate):
portal = self.getPortalObject()
folder_id = self.aq_parent.id
# Find a business template which manages the context skin folder.
folder_id_set = set([folder_id])
folder_id_set = {folder_id}
for template in portal.portal_templates.getInstalledBusinessTemplateList():
template_skin_id_list = template.getTemplateSkinIdList()
if folder_id in template_skin_id_list:
folder_id_set.update(set(template_skin_id_list))
folder_id_set.update(template_skin_id_list)
# Find folders which can be surcharged by this skin folder
if '_' in folder_id:
......
......@@ -896,10 +896,10 @@ class ListBoxRenderer:
Make sure there is no duplicates.
"""
all_column_list = list(self.getColumnList())
all_column_id_set = set([c[0] for c in all_column_list])
all_column_list.extend([(str(c[0]), unicode(c[1], self.getEncoding())) \
for c in self.field.get_value('all_columns') \
if c[0] not in all_column_id_set])
all_column_id_set = {c[0] for c in all_column_list}
all_column_list.extend((str(c[0]), unicode(c[1], self.getEncoding()))
for c in self.field.get_value('all_columns')
if c[0] not in all_column_id_set)
return all_column_list
getAllColumnList = lazyMethod(getAllColumnList)
......@@ -1004,14 +1004,9 @@ class ListBoxRenderer:
"""
search_columns = self.field.get_value('search_columns')
if search_columns:
search_column_id_list = [c[0] for c in search_columns]
else:
search_column_id_list = []
isValidColumn = self.getCatalogTool().getSQLCatalog().isValidColumn
for column_id, column_title in self.getAllColumnList():
if isValidColumn(column_id):
search_column_id_list.append(column_id)
return set(search_column_id_list)
return {c[0] for c in search_columns}
isValidColumn = self.getCatalogTool().getSQLCatalog().isValidColumn
return {id for id, title in self.getAllColumnList() if isValidColumn(id)}
getSearchColumnIdSet = lazyMethod(getSearchColumnIdSet)
......@@ -1020,10 +1015,8 @@ class ListBoxRenderer:
"""
sort_columns = self.field.get_value('sort_columns')
if sort_columns:
sort_column_id_set = set([c[0] for c in sort_columns])
else:
sort_column_id_set = self.getSearchColumnIdSet()
return sort_column_id_set
return {c[0] for c in sort_columns}
return self.getSearchColumnIdSet()
getSortColumnIdSet = lazyMethod(getSortColumnIdSet)
......@@ -1031,7 +1024,7 @@ class ListBoxRenderer:
"""Return the set of the ids of the editable columns.
"""
editable_columns = self.field.get_value('editable_columns')
return set([c[0] for c in editable_columns])
return {c[0] for c in editable_columns}
getEditableColumnIdSet = lazyMethod(getEditableColumnIdSet)
......@@ -1309,7 +1302,7 @@ class ListBoxRenderer:
field = self.field
original_field_id = field.id
while True:
for field_id in set((original_field_id, field.id)):
for field_id in {original_field_id, field.id}:
if field.aq_parent.has_field("%s_%s" % (field_id, alias), include_disabled=1):
return field.aq_parent.get_field("%s_%s" % (field_id, alias),
include_disabled=1)
......
......@@ -1511,7 +1511,7 @@ class SelectionTool( BaseTool, SimpleItem ):
def _getSelectionNameListFromContainer(self):
user_id = self._getUserId()
return list(set(self._getContainer().getSelectionNameList(user_id) + \
return list(set(self._getContainer().getSelectionNameList(user_id) +
self.getTemporarySelectionDict().keys()))
def isAnonymous(self):
......
......@@ -169,8 +169,8 @@ class TestDocumentMixin(ERP5TypeTestCase):
self.abort()
self.clearRestrictedSecurityHelperScript()
activity_tool = self.portal.portal_activities
activity_status = set(m.processing_node < -1
for m in activity_tool.getMessageList())
activity_status = {m.processing_node < -1
for <