ugly code to convert to Garmin API payload
This commit is contained in:
@@ -265,6 +265,16 @@ def step_to_garmin(step,order=0):
|
|||||||
targetValue = None
|
targetValue = None
|
||||||
except KeyError:
|
except KeyError:
|
||||||
targetValue = None
|
targetValue = None
|
||||||
|
|
||||||
|
if targetType is not None and targetType.lower() == "power":
|
||||||
|
targetType = 'POWER'
|
||||||
|
if targetValue is not None and targetValue <= 1000:
|
||||||
|
targetValueType = 'PERCENT'
|
||||||
|
else:
|
||||||
|
targetValueType = None
|
||||||
|
targetValue -= 1000
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
targetValueLow = step['dict']['targetValueLow']
|
targetValueLow = step['dict']['targetValueLow']
|
||||||
if targetValueLow == 0 and targetValue is not None and targetValue > 0:
|
if targetValueLow == 0 and targetValue is not None and targetValue > 0:
|
||||||
@@ -272,6 +282,10 @@ def step_to_garmin(step,order=0):
|
|||||||
targetValue = None
|
targetValue = None
|
||||||
elif targetValueLow == 0: # pragma: no cover
|
elif targetValueLow == 0: # pragma: no cover
|
||||||
targetValueLow = None
|
targetValueLow = None
|
||||||
|
elif targetValueLow <= 1000 and targetType == 'POWER':
|
||||||
|
targetValueType = 'PERCENT'
|
||||||
|
elif targetValueLow > 1000 and targetType == 'POWER':
|
||||||
|
targetValueLow -= 1000
|
||||||
except KeyError:
|
except KeyError:
|
||||||
targetValueLow = None
|
targetValueLow = None
|
||||||
try:
|
try:
|
||||||
@@ -279,26 +293,15 @@ def step_to_garmin(step,order=0):
|
|||||||
if targetValue is not None and targetValue > 0 and targetValueHigh == 0:
|
if targetValue is not None and targetValue > 0 and targetValueHigh == 0:
|
||||||
targetValueHigh = targetValue
|
targetValueHigh = targetValue
|
||||||
targetValue = 0
|
targetValue = 0
|
||||||
|
elif targetValueHigh <= 1000 and targetType == 'POWER':
|
||||||
|
targetValueType = 'PERCENT'
|
||||||
|
elif targetValueHigh > 1000 and targetType == 'POWER':
|
||||||
|
targetValueHigh -= 1000
|
||||||
elif targetValueHigh == 0: # pragma: no cover
|
elif targetValueHigh == 0: # pragma: no cover
|
||||||
targetValueHigh = None
|
targetValueHigh = None
|
||||||
except KeyError:
|
except KeyError:
|
||||||
targetValueHigh = None
|
targetValueHigh = None
|
||||||
|
|
||||||
if targetType is not None and targetType.lower() == "power":
|
|
||||||
targetType = 'POWER'
|
|
||||||
#if targetValue is not None and targetValue > 1000:
|
|
||||||
# targetValue -= 1000
|
|
||||||
#if targetValueHigh is not None and targetValueHigh > 1000: # pragma: no cover
|
|
||||||
# targetValueHigh -= 1000
|
|
||||||
#if targetValueLow is not None and targetValueLow > 1000: # pragma: no cover
|
|
||||||
# targetValueLow -= 1000
|
|
||||||
|
|
||||||
# temp - throw away target other than power
|
|
||||||
#if targetType is not None and targetType.lower() != 'power':
|
|
||||||
# targetType = None
|
|
||||||
# targetValue = None
|
|
||||||
# targetValueLow = None
|
|
||||||
# targetValueHigh = None
|
|
||||||
|
|
||||||
if targetValue is None and targetValueLow is None and targetValueHigh is None:
|
if targetValue is None and targetValueLow is None and targetValueHigh is None:
|
||||||
targetType = None
|
targetType = None
|
||||||
|
|||||||
Reference in New Issue
Block a user