Commit 459c9296 authored by Jérome Perrin's avatar Jérome Perrin Committed by Arnaud Fontaine

trade: pylint py3

parent ea482ceb
......@@ -87,7 +87,7 @@ class DeliveryRuleMovementGenerator(MovementGeneratorMixin):
# This is bad XXX-JPS - use use
"""
return None
return ()
def _getInputMovementList(self, movement_list=None, rounding=None):
"""Input movement list comes from delivery"""
......
......@@ -29,40 +29,37 @@ def rank_method(trade_condition):
if destination_section:
destination_section_group = trade_condition.getDestinationSectionValue().getGroup()
if destination_section == context.getDestinationSection():
rank += 10
rank -= 10
else:
rank -= 2
rank += 2
destination = trade_condition.getDestination()
if destination:
if destination == context.getDestination():
rank += 10
rank -= 10
else:
rank -= 2
rank += 2
if trade_condition.getSourceSection():
rank += 1
rank -= 1
if destination_section_group:
source_section_group = trade_condition.getSourceSectionValue().getGroup()
if source_section_group:
if source_section_group.startswith(destination_section_group) \
or destination_section_group.startswith(source_section_group):
# trade conditions where both sections are in the same group must have high priority
rank += 20
rank -= 20
if trade_condition.getSource():
rank += 1
rank += len(trade_condition.getSpecialiseList())
rank -= 1
rank -= len(trade_condition.getSpecialiseList())
if trade_condition.getValidationState() == 'validated':
rank += 2
rank -= 2
return rank
def sort_method(a, b):
return -cmp(rank_method(a), rank_method(b))
while count > 0 and len(trade_condition_list) == 0:
count -= 1
trade_condition_list = context.portal_domains.searchPredicateList(
predicate_context, portal_type=trade_condition_portal_type_list,
tested_base_category_list=tested_base_category_list[:count],
sort_method=sort_method)
sort_key_method=rank_method)
keep_items = {}
if len(trade_condition_list ) == 0 :
......
......@@ -27,33 +27,30 @@ def rank_method(trade_condition):
source_section = trade_condition.getSourceSection()
if source_section:
if source_section == context.getSourceSection():
rank += 10
rank -= 10
else:
rank -= 2
rank += 2
source = trade_condition.getSource()
if source:
if source == context.getSource():
rank += 10
rank -= 10
else:
rank -= 2
rank += 2
if trade_condition.getDestinationSection():
rank += 1
rank -= 1
if trade_condition.getDestination():
rank += 1
rank += len(trade_condition.getSpecialiseList())
rank -= 1
rank -= len(trade_condition.getSpecialiseList())
if trade_condition.getValidationState() == 'validated':
rank += 2
rank -= 2
return rank
def sort_method(a, b):
return -cmp(rank_method(a), rank_method(b))
while count > 0 and len(trade_condition_list) == 0:
count -= 1
trade_condition_list = context.portal_domains.searchPredicateList(
predicate_context, portal_type=trade_condition_portal_type,
tested_base_category_list=tested_base_category_list[:count],
sort_method=sort_method)
sort_key_method=rank_method)
keep_items = {}
if len(trade_condition_list ) == 0 :
......
......@@ -28,35 +28,32 @@ def rank_method(trade_condition):
destination_project = trade_condition.getDestinationProject()
if destination_project:
if destination_project == context.getDestinationProject():
rank += 10
rank -= 10
else:
rank -= 2
rank += 2
destination_section = trade_condition.getDestinationSection()
if destination_section:
if destination_section == context.getDestinationSection():
rank += 10
rank -= 10
else:
rank -= 2
rank += 2
destination = trade_condition.getDestination()
if destination:
if destination == context.getDestination():
rank += 10
rank -= 10
else:
rank -= 2
rank += 2
if trade_condition.getSourceProject():
rank += 1
rank -= 1
if trade_condition.getSourceSection():
rank += 1
rank -= 1
if trade_condition.getSource():
rank += 1
rank += len(trade_condition.getSpecialiseList())
rank -= 1
rank -= len(trade_condition.getSpecialiseList())
if trade_condition.getValidationState() == 'validated':
rank += 2
rank -= 2
return rank
def sort_method(a, b):
return -cmp(rank_method(a), rank_method(b))
def filter_method(trade_condition_list):
# Reject trade condition which has a non different value than the order
filtered_trade_condition_list = []
......@@ -76,7 +73,7 @@ while count > 0 and len(trade_condition_list) == 0:
predicate_context, portal_type=trade_condition_portal_type,
tested_base_category_list=tested_base_category_list[:count],
filter_method=filter_method,
sort_method=sort_method)
sort_key_method=rank_method)
keep_items = {}
if len(trade_condition_list ) == 0 :
......
......@@ -70,7 +70,6 @@ with ImmediateReindexContextManager() as immediate_reindex_context_manager:
line_variation_base_category_list = line_variation_base_category_dict.keys()
# construct new content (container_line)
resource_url = resource_url
new_container_line_id = str(container.generateNewId())
container_line = container.newContent(
immediate_reindex=immediate_reindex_context_manager,
......
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