Skip to content

Commit

Permalink
small fix
Browse files Browse the repository at this point in the history
  • Loading branch information
joamag committed Jan 31, 2017
1 parent 2be9935 commit caf42e8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/budy/models/measurement.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ def from_omni(
value_s = value

# tries converts the value into an integer value, falling back
# to the default (minus one) value in case it's not possible
# to the absolute hash value of it in case there's an error
try: value = int(value)
except ValueError: value = -1
except ValueError: value = cls._increment("measurement:value")

# tries to retrieve a measurement that is considered to be equivalent
# to the one described by the associated subproduct in case it does
Expand All @@ -164,7 +164,6 @@ def from_omni(
product = _product.id,
name = name,
value = value,
value_s = value_s,
raise_e = False
)
if not measurement: measurement = cls()
Expand Down Expand Up @@ -244,9 +243,10 @@ def duplicate_s(self):
self.product.save()
return measurement

def _fix_value_s(self, default = -1):
def _fix_value_s(self):
cls = self.__class__
try: self.value = int(self.value)
except ValueError: self.value = default
except ValueError: self.value = cls._increment("measurement:value")
self.save()

def _fix_invalid_s(self):
Expand Down

0 comments on commit caf42e8

Please sign in to comment.