Commit 51a2ac3f authored by Romain Courteaud's avatar Romain Courteaud

Remove some try / except with no exception.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3280 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 0a86e87b
...@@ -217,17 +217,20 @@ class Amount(Base, Variated): ...@@ -217,17 +217,20 @@ class Amount(Base, Variated):
getVariationRangeBaseCategoryList -> notion of getVariationRangeBaseCategoryList -> notion of
getVariationBaseCategoryList is different getVariationBaseCategoryList is different
""" """
try: resource = self.getDefaultResourceValue()
return self.getDefaultResourceValue().getVariationBaseCategoryList() if resource is not None:
except: result = resource.getVariationBaseCategoryList()
return self.portal_categories.getBaseCategoryList() else:
result = self.portal_categories.getBaseCategoryList()
return result
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getQuantityUnitRangeItemList') 'getQuantityUnitRangeItemList')
def getQuantityUnitRangeItemList(self, base_category_list=()): def getQuantityUnitRangeItemList(self, base_category_list=()):
try: resource = self.getDefaultResourceValue()
result = self.getDefaultResourceValue().getQuantityUnitList() if resource is not None:
except: result = resource.getQuantityUnitList()
else:
result = () result = ()
if result is (): if result is ():
return self.portal_categories.quantity_unit.getFormItemList() return self.portal_categories.quantity_unit.getFormItemList()
...@@ -240,13 +243,11 @@ class Amount(Base, Variated): ...@@ -240,13 +243,11 @@ class Amount(Base, Variated):
""" """
Return default quantity unit of the resource Return default quantity unit of the resource
""" """
try: resource = self.getResourceValue()
#if 1: resource_quantity_unit = None
resource = self.getResourceValue() if resource is not None:
resource_quantity_unit = resource.getDefaultQuantityUnit() resource_quantity_unit = resource.getDefaultQuantityUnit()
except:
#LOG("ERP5 WARNING:", 100, 'could not convert quantity for %s' % self.getRelativeUrl()) #LOG("ERP5 WARNING:", 100, 'could not convert quantity for %s' % self.getRelativeUrl())
resource_quantity_unit = None
return resource_quantity_unit return resource_quantity_unit
security.declareProtected(Permissions.AccessContentsInformation, 'getResourcePrice') security.declareProtected(Permissions.AccessContentsInformation, 'getResourcePrice')
...@@ -281,11 +282,11 @@ class Amount(Base, Variated): ...@@ -281,11 +282,11 @@ class Amount(Base, Variated):
""" """
Return duration in minute Return duration in minute
""" """
try: result = None
efficiency = self.getEfficiency() efficiency = self.getEfficiency()
return self.getResourcePrice() * self.getConvertedQuantity() / efficiency if efficiency != 0:
except: result = self.getResourcePrice() * self.getConvertedQuantity() / efficiency
return None return result
...@@ -295,28 +296,26 @@ class Amount(Base, Variated): ...@@ -295,28 +296,26 @@ class Amount(Base, Variated):
""" """
Converts quantity to default unit Converts quantity to default unit
""" """
try: resource = self.getResourceValue()
#if 1: quantity_unit = self.getQuantityUnit()
resource = self.getResourceValue() quantity = self.getQuantity()
converted_quantity = None
if resource is not None:
resource_quantity_unit = resource.getDefaultQuantityUnit() resource_quantity_unit = resource.getDefaultQuantityUnit()
quantity_unit = self.getQuantityUnit()
quantity = self.getQuantity()
converted_quantity = resource.convertQuantity(quantity, quantity_unit, resource_quantity_unit) converted_quantity = resource.convertQuantity(quantity, quantity_unit, resource_quantity_unit)
except: else:
LOG("ERP5 WARNING:", 100, 'could not convert quantity for %s' % self.getRelativeUrl()) LOG("ERP5 WARNING:", 100, 'could not convert quantity for %s' % self.getRelativeUrl())
converted_quantity = None
return converted_quantity return converted_quantity
security.declareProtected(Permissions.ModifyPortalContent, 'setConvertedQuantity') security.declareProtected(Permissions.ModifyPortalContent, 'setConvertedQuantity')
def setConvertedQuantity(self, value): def setConvertedQuantity(self, value):
try: resource = self.getResourceValue()
#if 1: quantity_unit = self.getQuantityUnit()
resource = self.getResourceValue() if resource is not None:
resource_quantity_unit = resource.getDefaultQuantityUnit() resource_quantity_unit = resource.getDefaultQuantityUnit()
quantity_unit = self.getQuantityUnit()
quantity = resource.convertQuantity(value, resource_quantity_unit, quantity_unit) quantity = resource.convertQuantity(value, resource_quantity_unit, quantity_unit)
self.setQuantity(quantity) self.setQuantity(quantity)
except: else:
LOG("ERP5 WARNING:", 100, 'could not set converted quantity for %s' % self.getRelativeUrl()) LOG("ERP5 WARNING:", 100, 'could not set converted quantity for %s' % self.getRelativeUrl())
security.declareProtected(Permissions.AccessContentsInformation, 'getNetQuantity') security.declareProtected(Permissions.AccessContentsInformation, 'getNetQuantity')
...@@ -414,9 +413,9 @@ class Amount(Base, Variated): ...@@ -414,9 +413,9 @@ class Amount(Base, Variated):
source = self.getSource() source = self.getSource()
destination = self.getDestination() destination = self.getDestination()
try: if quantity is not None:
quantity = float(quantity) quantity = float(quantity)
except: else:
quantity = 0.0 quantity = 0.0
if source in (None, ''): if source in (None, ''):
...@@ -440,9 +439,9 @@ class Amount(Base, Variated): ...@@ -440,9 +439,9 @@ class Amount(Base, Variated):
source = self.getSource() source = self.getSource()
destination = self.getDestination() destination = self.getDestination()
try: if quantity is not None:
quantity = float(quantity) quantity = float(quantity)
except: else:
quantity = 0.0 quantity = 0.0
if destination in (None, ''): if destination in (None, ''):
...@@ -465,9 +464,9 @@ class Amount(Base, Variated): ...@@ -465,9 +464,9 @@ class Amount(Base, Variated):
source = self.getSource() source = self.getSource()
destination = self.getDestination() destination = self.getDestination()
try: if quantity is not None:
quantity = float(value) quantity = float(quantity)
except: else:
quantity = 0.0 quantity = 0.0
if source in (None, ''): if source in (None, ''):
...@@ -490,9 +489,9 @@ class Amount(Base, Variated): ...@@ -490,9 +489,9 @@ class Amount(Base, Variated):
source = self.getSource() source = self.getSource()
destination = self.getDestination() destination = self.getDestination()
try: if quantity is not None:
quantity = float(value) quantity = float(quantity)
except: else:
quantity = 0.0 quantity = 0.0
if destination in (None, ''): if destination in (None, ''):
......
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