Commit 4568cc17 authored by Jérome Perrin's avatar Jérome Perrin

budget: fix pylint messages and enable coding style

Not that the old `reversed` function was different from the builtin, we
replace it with sorted(reverse=True) to keep the same logic.
parent 468da0e3
# We don't have good implementation of budget predicate yet, so don't fill predicate table for now. # We don't have good implementation of budget predicate yet, so don't fill predicate table for now.
return None return None
# XXX strict membership is missing ?
# ideally strict membership should be an option for each category, but this API
# does not exist in predicates.
# TODO: support virtual "All other nodes" # TODO: support virtual "All other nodes"
return context.generatePredicate(
multimembership_criterion_base_category_list = ('resource',),
criterion_property_list = ('start_date', 'stop_date'))
# We don't have good implementation of budget predicate yet, so don't fill predicate table for now. # We don't have good implementation of budget predicate yet, so don't fill predicate table for now.
return None return None
context = context.asContext(
_range_criterion = {'start_date': (context.getStartDateRangeMin(),
context.getStartDateRangeMax())
})
return context
return context.generatePredicate(criterion_property_list=('start_date', 'stop_date'))
return context.generatePredicate(_range_criterion = {'start_date': (context.getStartDate(),
context.getStopDate())
})
return context.generatePredicate(criterion_property_list=('start_date',))
return context.generatePredicate(multimembership_criterion_base_category_list = ('resource',),
criterion_property_list = ('start_date',))
context = context.asContext(
criterion_property_list=['start_date'],
range_criterion = {'start_date': (context.getStartDate(),
context.getStopDate())
})
return context
...@@ -28,16 +28,11 @@ if budget_model is not None: ...@@ -28,16 +28,11 @@ if budget_model is not None:
non_strict_base_category_set[ non_strict_base_category_set[
budget_variation.getProperty('variation_base_category')] = True budget_variation.getProperty('variation_base_category')] = True
def reversed(seq):
seq = seq[::]
seq.sort(reverse=True)
return seq
# build a dict of dependant dimensions # build a dict of dependant dimensions
dependant_dimensions_dict = {} dependant_dimensions_dict = {}
for bc in non_strict_base_category_set.keys(): for bc in non_strict_base_category_set.keys():
vcl = reversed(context.getVariationCategoryList(base_category_list=(bc,))) vcl = sorted(context.getVariationCategoryList(base_category_list=(bc,)), reverse=True)
for vc in vcl: for vc in vcl:
dependant_vc_list = [other_vc for other_vc in vcl dependant_vc_list = [other_vc for other_vc in vcl
if other_vc.startswith('%s/' % vc) if other_vc.startswith('%s/' % vc)
......
if default_sub_field_property_dict is None:
default_sub_field_property_dict = {}
# Remove empty items # Remove empty items
item_list = filter(lambda x: x not in [('',''), ['','']],\ item_list = [x for x in item_list if x not in (('',''), ['',''])]
item_list)
sub_field_dict = {} sub_field_dict = {}
split_depth = 1 split_depth = 1
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>item_list, value_list, default_sub_field_property_dict={}, is_right_display=0</string> </value> <value> <string>item_list, value_list, default_sub_field_property_dict=None, is_right_display=0</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
from Products.ERP5Type.Utils import cartesianProduct from Products.ERP5Type.Utils import cartesianProduct
from Products.ERP5Type.Message import translateString from Products.ERP5Type.Message import translateString
updated_cell_count = 0 updated_cell_count = 0
dependant_dimensions_dict = context.BudgetLine_getSummaryDimensionKeyDict() dependant_dimensions_dict = context.BudgetLine_getSummaryDimensionKeyDict()
cell_key_list = context.getCellKeyList() cell_key_list = context.getCellKeyList()
def reversed(seq):
seq = seq[::]
seq.sort(reverse=True)
return seq
# we iterate in reversed order to update the deepest cells first # we iterate in reversed order to update the deepest cells first
for cell_key in reversed(cartesianProduct(context.getCellRange())): for cell_key in sorted(cartesianProduct(context.getCellRange()), reverse=True):
for idx, dimension in enumerate(cell_key): for idx, dimension in enumerate(cell_key):
if dimension in dependant_dimensions_dict: if dimension in dependant_dimensions_dict:
dependant_cell_list = [] dependant_cell_list = []
......
if default_sub_field_property_dict is None:
default_sub_field_property_dict = {}
# Remove empty items # Remove empty items
item_list = filter(lambda x: x not in [('',''), ['','']],\ item_list = [x for x in item_list if x not in (('',''), ['',''])]
item_list)
sub_field_dict = {} sub_field_dict = {}
split_depth = 1 split_depth = 1
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>item_list, value_list, default_sub_field_property_dict={}, is_right_display=0</string> </value> <value> <string>item_list, value_list, default_sub_field_property_dict=None, is_right_display=0</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
...@@ -10,7 +10,7 @@ if line.getMembershipCriterionBaseCategoryList(): ...@@ -10,7 +10,7 @@ if line.getMembershipCriterionBaseCategoryList():
for variation in budget_line_category_list: for variation in budget_line_category_list:
if not variation: if not variation:
continue continue
base, category = variation.split('/', 1) base = variation.split('/', 1)[0]
if base in line.getMembershipCriterionBaseCategoryList(): if base in line.getMembershipCriterionBaseCategoryList():
line.setMembershipCriterionCategoryList( line.setMembershipCriterionCategoryList(
[variation,] + line.getMembershipCriterionCategoryList()) [variation,] + line.getMembershipCriterionCategoryList())
from Products.DCWorkflow.DCWorkflow import ValidationFailed state_change['object'].Base_checkConsistency()
object = state_change['object']
error_msg = 'Please correct the following errors:'
consistency = object.checkConsistency()
for elem in consistency:
error_msg =error_msg+' '+elem[4]
if consistency != []:
raise ValidationFailed, str(error_msg)
object = state_change['object'] state_change['object'].Base_checkConsistency()
object.Base_checkConsistency()
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