fix function
aka, bruteforcing the build to make up for my lack of python skillz
@@ -297,15 +297,18 @@ class EndomondoService(ServiceBase):
csp.update(SECRET_KEY.encode("utf-8"))
return "tap-" + csp.hexdigest()
- def _shouldUseOriginalSport(self, activity):
+ def _getSport(activity):
# This is an activity type that doesn't round trip
- return (activity.Type in self._activitiesThatDontRoundTrip and
+ if (activity.Type in _activitiesThatDontRoundTrip and
# We have the original sport
"Sport" in activity.ServiceData and
# We know what this sport is
- activity.ServiceData["Sport"] in self._activityMappings and
+ activity.ServiceData["Sport"] in _activityMappings and
# The type didn't change (if we changed from Walking to Cycling, we'd want to let the new value through)
- activity.Type == self._activityMappings[activity.ServiceData["Sport"]])
+ activity.Type == _activityMappings[activity.ServiceData["Sport"]])
+ return activity.ServiceData["Sport"]
+ else
+ return [k for k,v in self._reverseActivityMappings.items() if v == activity.Type][0]
def UploadActivity(self, serviceRecord, activity):
session = self._oauthSession(serviceRecord)
@@ -328,11 +331,7 @@ class EndomondoService(ServiceBase):
activity_id = "tap-" + activity.UID + "-" + str(os.getpid())
- if self._shouldUseOriginalSport(activity)
- # it's something that doesn't round trip, use the original
- sport = activity.ServiceData["Sport"]
- else
- sport = [k for k,v in self._reverseActivityMappings.items() if v == activity.Type][0]
+ sport = self._getSport(activity)
upload_data = {
"device_id": device_id,
