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

*: fix used-before-assignment and possibly-used-before-assignment from pylint 3.2.0

parent b57fb15c
...@@ -64,35 +64,35 @@ line_list = context.AccountingTransaction_getAccountingTransactionLineList( ...@@ -64,35 +64,35 @@ line_list = context.AccountingTransaction_getAccountingTransactionLineList(
if not cancellation_amount: if not cancellation_amount:
line_list.reverse() line_list.reverse()
# guess portal_type to create lines
if line_list: if line_list:
# guess portal_type to create lines
line_portal_type = line_list[0].getPortalType() line_portal_type = line_list[0].getPortalType()
for line in line_list: for line in line_list:
new_line = reversal.newContent( portal_type=line_portal_type ) new_line = reversal.newContent( portal_type=line_portal_type )
new_line.edit( new_line.edit(
source=line.getSource(portal_type='Account'), source=line.getSource(portal_type='Account'),
destination=line.getDestination(portal_type='Account'), destination=line.getDestination(portal_type='Account'),
quantity= - line.getQuantity(), ) quantity= - line.getQuantity(), )
if line.getSourceTotalAssetPrice(): if line.getSourceTotalAssetPrice():
new_line.setSourceTotalAssetPrice( - line.getSourceTotalAssetPrice() ) new_line.setSourceTotalAssetPrice( - line.getSourceTotalAssetPrice() )
if line.getDestinationTotalAssetPrice(): if line.getDestinationTotalAssetPrice():
new_line.setDestinationTotalAssetPrice( new_line.setDestinationTotalAssetPrice(
- line.getDestinationTotalAssetPrice() ) - line.getDestinationTotalAssetPrice() )
new_line.setCancellationAmount(cancellation_amount) new_line.setCancellationAmount(cancellation_amount)
# copy some values if they are defined explicitly on line # copy some values if they are defined explicitly on line
for prop in [ 'source_section', 'destination_section', for prop in [ 'source_section', 'destination_section',
'source_payment', 'destination_payment', 'source_payment', 'destination_payment',
'source_project', 'destination_project', 'source_project', 'destination_project',
'source_function', 'destination_function', 'source_function', 'destination_function',
'source_funding', 'destination_funding', 'source_funding', 'destination_funding',
'source_payment_request', 'destination_payment_request', 'source_payment_request', 'destination_payment_request',
'resource', 'product_line', 'string_index' ]: 'resource', 'product_line', 'string_index' ]:
if line.getProperty(prop) != context.getProperty(prop): if line.getProperty(prop) != context.getProperty(prop):
new_line.setProperty(prop, line.getProperty(prop)) new_line.setProperty(prop, line.getProperty(prop))
if plan: if plan:
reversal.plan() reversal.plan()
......
...@@ -55,6 +55,7 @@ shopping_cart_items = context.SaleOrder_getShoppingCartItemList() ...@@ -55,6 +55,7 @@ shopping_cart_items = context.SaleOrder_getShoppingCartItemList()
# get category like size and variation # get category like size and variation
category = request.form.get('field_variation_box_your_category', '') category = request.form.get('field_variation_box_your_category', '')
base_category = ''
if category: if category:
[base_category, category] = category.split('/', 1) [base_category, category] = category.split('/', 1)
variation = request.form.get('field_variation_box_your_variation', None) variation = request.form.get('field_variation_box_your_variation', None)
......
...@@ -37,8 +37,7 @@ else: ...@@ -37,8 +37,7 @@ else:
variation_dict["start_date"] = date variation_dict["start_date"] = date
variation_dict["stop_date"] = date+0.00001 variation_dict["stop_date"] = date+0.00001
if web_site_value is not None: price_currency_value = web_site_value.WebSite_getShoppingCartDefaultCurrency()
price_currency_value = web_site_value.WebSite_getShoppingCartDefaultCurrency()
movement = context.newContent( movement = context.newContent(
temp_object=True, temp_object=True,
......
...@@ -28,6 +28,8 @@ elif aggregation_level == "week": ...@@ -28,6 +28,8 @@ elif aggregation_level == "week":
sql_format = "%Y-%u" sql_format = "%Y-%u"
elif aggregation_level == "day": elif aggregation_level == "day":
sql_format = "%Y-%m-%d" sql_format = "%Y-%m-%d"
else:
raise ValueError("Unsupported aggregation level %s" % aggregation_level)
if to_date is not None: if to_date is not None:
to_date = atTheEndOfPeriod(to_date, period=aggregation_level) to_date = atTheEndOfPeriod(to_date, period=aggregation_level)
count_kw = {} count_kw = {}
......
...@@ -30,7 +30,9 @@ import re ...@@ -30,7 +30,9 @@ import re
import six import six
if six.PY3: if six.PY3:
long = int # pylint:disable=redefined-builtin long_or_int = int
else:
long_or_int = long # pylint:disable=undefined-variable
class BigFile(File): class BigFile(File):
""" """
...@@ -189,13 +191,13 @@ class BigFile(File): ...@@ -189,13 +191,13 @@ class BigFile(File):
else: else:
# Date # Date
date = if_range.split( ';')[0] date = if_range.split( ';')[0]
try: mod_since=long(DateTime(date).timeTime()) try: mod_since=long_or_int(DateTime(date).timeTime())
except Exception: mod_since=None except Exception: mod_since=None
if mod_since is not None: if mod_since is not None:
last_mod = self._data_mtime() last_mod = self._data_mtime()
if last_mod is None: if last_mod is None:
last_mod = 0 last_mod = 0
last_mod = long(last_mod) last_mod = long_or_int(last_mod)
if last_mod > mod_since: if last_mod > mod_since:
# Modified, so send a normal response. We delete # Modified, so send a normal response. We delete
# the ranges, which causes us to skip to the 200 # the ranges, which causes us to skip to the 200
......
...@@ -81,6 +81,8 @@ class CategoriesSpreadsheetConfiguratorItem(ConfiguratorItemMixin, XMLObject): ...@@ -81,6 +81,8 @@ class CategoriesSpreadsheetConfiguratorItem(ConfiguratorItemMixin, XMLObject):
"Base Category %s should be created" % bc_id)) "Base Category %s should be created" % bc_id))
if fixit: if fixit:
bc = ctool.newContent(id=bc_id) bc = ctool.newContent(id=bc_id)
else:
continue
if fixit: if fixit:
for category_info in category_list: for category_info in category_list:
......
...@@ -226,6 +226,7 @@ class ConfiguratorTool(BaseTool): ...@@ -226,6 +226,7 @@ class ConfiguratorTool(BaseTool):
return response return response
## show next form in transitions ## show next form in transitions
html = None
rendered = False rendered = False
while rendered is False: while rendered is False:
if need_validation == 1: if need_validation == 1:
......
...@@ -11,6 +11,7 @@ Upgrade link for the specific type of display ...@@ -11,6 +11,7 @@ Upgrade link for the specific type of display
import re import re
link_href = re.findall("href=['\"](.*?)['\"]", link_string)[0] link_href = re.findall("href=['\"](.*?)['\"]", link_string)[0]
link_title = ''
# XXX flag if broken link # XXX flag if broken link
if link_href.find("http") == -1: if link_href.find("http") == -1:
......
...@@ -29,6 +29,7 @@ from Products.PythonScripts.standard import html_quote ...@@ -29,6 +29,7 @@ from Products.PythonScripts.standard import html_quote
from base64 import b64encode from base64 import b64encode
blank = '' blank = ''
slide_content = blank
flags = re.MULTILINE|re.DOTALL|re.IGNORECASE flags = re.MULTILINE|re.DOTALL|re.IGNORECASE
details_separator = '</section><section class="ci-notes-continue"><section><h1>cont.</h1></section>' details_separator = '</section><section class="ci-notes-continue"><section><h1>cont.</h1></section>'
pref = context.getPortalObject().portal_preferences pref = context.getPortalObject().portal_preferences
......
...@@ -22,6 +22,7 @@ def Listbox_getBrainValue(self, brain, obj, select, can_check_local_property, ed ...@@ -22,6 +22,7 @@ def Listbox_getBrainValue(self, brain, obj, select, can_check_local_property, ed
ListBox.py / getValueList ListBox.py / getValueList
""" """
tales = False tales = False
default_field_value = None
# Use a widget, if any. # Use a widget, if any.
if editable_field is not None: if editable_field is not None:
......
...@@ -4,8 +4,7 @@ Base_translateString = portal.Base_translateString ...@@ -4,8 +4,7 @@ Base_translateString = portal.Base_translateString
preserved_parameter_dict = {} preserved_parameter_dict = {}
Base_doAction = select_action.split() Base_doAction = select_action.split()
if len(Base_doAction) != 0: doAction0 = Base_doAction[0]
doAction0 = Base_doAction[0]
kw['keep_items'] = preserved_parameter_dict kw['keep_items'] = preserved_parameter_dict
......
...@@ -202,37 +202,37 @@ def generateDomainTreeList(url_tool, domain_tool, domain, depth, domain_list): ...@@ -202,37 +202,37 @@ def generateDomainTreeList(url_tool, domain_tool, domain, depth, domain_list):
def getDomainSelection(domain_list): def getDomainSelection(domain_list):
root_dict = {} root_dict = {}
if len(domain_list) > 0: if domain_list:
category_tool = portal.portal_categories category_tool = portal.portal_categories
domain_tool = portal.portal_domains domain_tool = portal.portal_domains
preference_tool = portal.portal_preferences preference_tool = portal.portal_preferences
url_tool = portal.portal_url url_tool = portal.portal_url
for base_domain_id in domain_list: for base_domain_id in domain_list:
domain = None domain = None
if category_tool is not None: if category_tool is not None:
domain = category_tool.restrictedTraverse(base_domain_id, None) domain = category_tool.restrictedTraverse(base_domain_id, None)
if domain is not None : if domain is not None :
root_dict[base_domain_id] = getattr( root_dict[base_domain_id] = getattr(
domain, domain,
preference_tool.getPreference( preference_tool.getPreference(
'preferred_category_child_item_list_method_id', 'preferred_category_child_item_list_method_id',
'getCategoryChildCompactLogicalPathItemList' 'getCategoryChildCompactLogicalPathItemList'
) )
)(local_sort_id=('int_index', 'translated_title'), checked_permission='View', )(local_sort_id=('int_index', 'translated_title'), checked_permission='View',
filter_node=0, display_none_category=0) filter_node=0, display_none_category=0)
elif domain_tool is not None: elif domain_tool is not None:
try: try:
domain = domain_tool.getDomainByPath(base_domain_id, None) domain = domain_tool.getDomainByPath(base_domain_id, None)
except KeyError: except KeyError:
domain = None domain = None
if domain is not None: if domain is not None:
# XXX Implement recursive fetch # XXX Implement recursive fetch
domain_list = [] domain_list = []
generateDomainTreeList(url_tool, domain_tool, domain, 0, domain_list) generateDomainTreeList(url_tool, domain_tool, domain, 0, domain_list)
root_dict[base_domain_id] = domain_list root_dict[base_domain_id] = domain_list
return root_dict return root_dict
...@@ -2169,7 +2169,7 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None, ...@@ -2169,7 +2169,7 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None,
# XXX If only available on brains, maybe better to call on aq_self # XXX If only available on brains, maybe better to call on aq_self
getBrainListItemUrlDict = getattr(brain, 'getListItemUrlDict', None) getBrainListItemUrlDict = getattr(brain, 'getListItemUrlDict', None)
is_getListItemUrlDict_calculated = True is_getListItemUrlDict_calculated = True
if getBrainListItemUrlDict is not None: if getBrainListItemUrlDict is not None: # pylint:disable=possibly-used-before-assignment
# Check if we can get URL result from the brain # Check if we can get URL result from the brain
try: try:
url_parameter_dict = getBrainListItemUrlDict( url_parameter_dict = getBrainListItemUrlDict(
......
...@@ -44,10 +44,9 @@ delivery_count = len(source_section_list) ...@@ -44,10 +44,9 @@ delivery_count = len(source_section_list)
for item in object_list: for item in object_list:
source_section = item.Item_getCurrentOwnerValue() source_section = item.Item_getCurrentOwnerValue()
if source_section is not None: if source_section is not None:
if source_section.getUid() is not None: pl_value = pl_dict[str(source_section.getUid())]
pl_value = pl_dict[str(source_section.getUid())]
else: else:
pl_value = pl_dict['UID'] pl_value = pl_dict['UID']
source = item.Item_getCurrentSiteValue() source = item.Item_getCurrentSiteValue()
resource = item.Item_getResourceValue() resource = item.Item_getResourceValue()
......
...@@ -12,7 +12,7 @@ for line in result: ...@@ -12,7 +12,7 @@ for line in result:
resource = line.getResourceValue() resource = line.getResourceValue()
if resource is not None: if resource is not None:
sender = line.getResourceValue().getPurchaseSupplyLineSource() sender = line.getResourceValue().getPurchaseSupplyLineSource()
line.setCategoryMembership('source', sender) line.setCategoryMembership('source', sender)
line.setCategoryMembership('price_currency', price_currency) line.setCategoryMembership('price_currency', price_currency)
return result return result
...@@ -16,7 +16,7 @@ if selection_name is not None: ...@@ -16,7 +16,7 @@ if selection_name is not None:
resource = line.getResourceValue() resource = line.getResourceValue()
if resource is not None: if resource is not None:
sender = line.getResourceValue().getPurchaseSupplyLineSource() sender = line.getResourceValue().getPurchaseSupplyLineSource()
line.setCategoryMembership('source', sender) line.setCategoryMembership('source', sender)
line.setCategoryMembership('price_currency', price_currency) line.setCategoryMembership('price_currency', price_currency)
result = aal.getTotalPrice() result = aal.getTotalPrice()
......
...@@ -52,12 +52,10 @@ for requirement_item in requirements_items: ...@@ -52,12 +52,10 @@ for requirement_item in requirements_items:
has_1st_level_requirement = True has_1st_level_requirement = True
new_1st_level_requirement = [] new_1st_level_requirement = []
new_1st_level_requirement_title = requirement_item['title'] new_1st_level_requirement_title = requirement_item['title']
description_dict[new_1st_level_requirement_title] = ''
else: else:
has_1st_level_requirement = False has_1st_level_requirement = False
if has_1st_level_requirement:
description_dict[new_1st_level_requirement_title] = ''
# the item has a second level requirement, built it # the item has a second level requirement, built it
if requirement_item['sub_title'] not in ('', None): if requirement_item['sub_title'] not in ('', None):
has_2nd_level_requirement = True has_2nd_level_requirement = True
......
...@@ -477,6 +477,7 @@ class ERP5Conduit(XMLSyncUtilsMixin): ...@@ -477,6 +477,7 @@ class ERP5Conduit(XMLSyncUtilsMixin):
if get_target_parent: if get_target_parent:
result_list = result_list[:-1] result_list = result_list[:-1]
first_object = True first_object = True
sub_context = None
while result_list: while result_list:
object_block = result_list[0][0] object_block = result_list[0][0]
sub_context_id = result_list[0][3] sub_context_id = result_list[0][3]
......
...@@ -21,7 +21,7 @@ if line_portal_type in portal.getPortalSaleTypeList(): ...@@ -21,7 +21,7 @@ if line_portal_type in portal.getPortalSaleTypeList():
section_uid = context.getSourceSectionUid() section_uid = context.getSourceSectionUid()
elif line_portal_type in portal.getPortalPurchaseTypeList(): elif line_portal_type in portal.getPortalPurchaseTypeList():
section_uid = context.getDestinationSectionUid() section_uid = context.getDestinationSectionUid()
elif line_portal_type in portal.getPortalInternalTypeList() + portal.getPortalInventoryMovementTypeList(): else:
section_uid = None section_uid = None
len_line_list = len(line_list) len_line_list = len(line_list)
used_id = [] # list use to make sure we do not generate two line with same id/uid used_id = [] # list use to make sure we do not generate two line with same id/uid
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
input information.It should take into account any trade document line input information.It should take into account any trade document line
which were already created so that they are not duplicated. which were already created so that they are not duplicated.
""" """
# pylint:disable=possibly-used-before-assignment
from Products.ERP5Type.Message import translateString from Products.ERP5Type.Message import translateString
portal = context.getPortalObject() portal = context.getPortalObject()
......
...@@ -43,6 +43,7 @@ elif line_portal_type in portal.getPortalInternalTypeList(): ...@@ -43,6 +43,7 @@ elif line_portal_type in portal.getPortalInternalTypeList():
elif line_portal_type in portal.getPortalInventoryMovementTypeList(): elif line_portal_type in portal.getPortalInventoryMovementTypeList():
section_uid = None section_uid = None
no_inventory = True no_inventory = True
supply_cell_portal_type = supply_line_id = None
use_list = portal.portal_preferences.getPreferredPurchaseUseList() \ use_list = portal.portal_preferences.getPreferredPurchaseUseList() \
+ portal.portal_preferences.getPreferredSaleUseList() + portal.portal_preferences.getPreferredSaleUseList()
else: else:
......
...@@ -51,6 +51,8 @@ elif aggregation_level == "week": ...@@ -51,6 +51,8 @@ elif aggregation_level == "week":
date_format = "%Y-%U" date_format = "%Y-%U"
elif aggregation_level == "day": elif aggregation_level == "day":
date_format = "%Y-%m-%d" date_format = "%Y-%m-%d"
else:
raise ValueError("Unsupported aggregation_level: %s" % aggregation_level)
if from_date is not None and at_date is not None: if from_date is not None and at_date is not None:
catalog_params['delivery.start_date'] = { catalog_params['delivery.start_date'] = {
......
...@@ -247,6 +247,7 @@ if force_base_url: ...@@ -247,6 +247,7 @@ if force_base_url:
root_url = "/".join(base_url.split("/", 3)[:3]) root_url = "/".join(base_url.split("/", 3)[:3])
if root_url != base_url: if root_url != base_url:
base_url = "/".join(base_url.split("/")[:-1]) base_url = "/".join(base_url.split("/")[:-1])
request_protocol = 'https:'
else: else:
request_protocol = context.REQUEST.SERVER_URL.split(":", 1)[0] + ":" request_protocol = context.REQUEST.SERVER_URL.split(":", 1)[0] + ":"
root_url = base_url_root_object.absolute_url() root_url = base_url_root_object.absolute_url()
......
...@@ -989,7 +989,8 @@ class ImmobilisableItem(Item, Amount): ...@@ -989,7 +989,8 @@ class ImmobilisableItem(Item, Amount):
raw_annuity_price = annuity_start_price * current_ratio raw_annuity_price = annuity_start_price * current_ratio
elif price_calculation_basis == "period recalculated start price": elif price_calculation_basis == "period recalculated start price":
raw_annuity_price = local_period_start_price * current_ratio raw_annuity_price = local_period_start_price * current_ratio
else:
raise ValueError("Unsupported price_calculation_basis: %s" % price_calculation_basis)
# Apply the prorata temporis on the raw annuity value # Apply the prorata temporis on the raw annuity value
if annuity_number and \ if annuity_number and \
price_calculation_basis == 'period recalculated start price' and \ price_calculation_basis == 'period recalculated start price' and \
......
...@@ -271,6 +271,7 @@ class AmountGeneratorMixin: ...@@ -271,6 +271,7 @@ class AmountGeneratorMixin:
- is rounding really well supported (ie. before and after aggregation) - is rounding really well supported (ie. before and after aggregation)
very likely not - proxying before or after must be decided very likely not - proxying before or after must be decided
""" """
# pylint:disable=self-cls-assignment,possibly-used-before-assignment
# It is the only place where we can import this # It is the only place where we can import this
portal = self.getPortalObject() portal = self.getPortalObject()
getRoundingProxy = portal.portal_roundings.getRoundingProxy getRoundingProxy = portal.portal_roundings.getRoundingProxy
......
...@@ -85,7 +85,7 @@ class _Policy(object): ...@@ -85,7 +85,7 @@ class _Policy(object):
if attr == 'merge_parent': if attr == 'merge_parent':
self.merge_parent = value = self.context.getRootAppliedRule().getPath() self.merge_parent = value = self.context.getRootAppliedRule().getPath()
else: else:
object.__getattribute__(self, attr) value = object.__getattribute__(self, attr)
return value return value
def deferAll(self): def deferAll(self):
......
...@@ -8,6 +8,7 @@ request=context.REQUEST ...@@ -8,6 +8,7 @@ request=context.REQUEST
# We stop doing this # We stop doing this
#base_category = context.getBaseCategoryId() #base_category = context.getBaseCategoryId()
base_category = None base_category = None
redirect_url = None
o = context.restrictedTraverse(object_path) o = context.restrictedTraverse(object_path)
......
...@@ -42,7 +42,7 @@ skin_id_list = context.getTemplateSkinIdList() ...@@ -42,7 +42,7 @@ skin_id_list = context.getTemplateSkinIdList()
if skin_id_list: if skin_id_list:
if bt_title in skin_id_list: if bt_title in skin_id_list:
main_skin_id = bt_title main_skin_id = bt_title
elif skin_id_list: else:
main_skin_id = skin_id_list[0] main_skin_id = skin_id_list[0]
form_path = '%s/%s' % (main_skin_id, field_library_id) form_path = '%s/%s' % (main_skin_id, field_library_id)
form = getForm(portal.portal_skins[main_skin_id], field_library_id) form = getForm(portal.portal_skins[main_skin_id], field_library_id)
......
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