def get_profile_photo(self, size='medium'): if size not in ('small', 'medium', 'large'): raise InvalidSizeException('User get_profile_photo size must one of "small", "medium" or "large".') from mapmyfitness import MapMyFitness instance = MapMyFitness.instance() user_profile_photo = instance._user_profile_photo.find(self.id) return getattr(user_profile_photo, size)
def get_profile_photo(self, size='medium'): if size not in ('small', 'medium', 'large'): raise InvalidSizeException( 'User get_profile_photo size must one of "small", "medium" or "large".' ) from mapmyfitness import MapMyFitness instance = MapMyFitness.instance() user_profile_photo = instance._user_profile_photo.find(self.id) return getattr(user_profile_photo, size)
def activity_type(self): if hasattr(self, '_activity_type'): return self._activity_type else: from mapmyfitness import MapMyFitness instance = MapMyFitness.instance() activity_type = instance.activity_type.find(self.activity_type_id) self._activity_type = activity_type return self._activity_type
def activity_type(self): if hasattr(self, "_activity_type"): return self._activity_type else: from mapmyfitness import MapMyFitness instance = MapMyFitness.instance() activity_type = instance.activity_type.find(self.activity_type_id) self._activity_type = activity_type return self._activity_type
def route(self): if self.route_id: if hasattr(self, '_route'): return self._route else: from mapmyfitness import MapMyFitness instance = MapMyFitness.instance() route = instance.route.find(self.route_id) self._route = route return self._route
def root_activity_type(self): if not self.has_parent: return self if hasattr(self, '_activity_type'): return self._activity_type else: from mapmyfitness import MapMyFitness instance = MapMyFitness.instance() activity_type = instance.activity_type.find(self.root_activity_type_id) self._activity_type = activity_type return self._activity_type
def time_series(self): if self.has_time_series: if 'time_series' in self.original_dict: return self.original_dict['time_series'] elif hasattr(self, '_time_series'): return self._time_series else: from mapmyfitness import MapMyFitness instance = MapMyFitness.instance() workout = instance.workout.find(self.id) self._time_series = workout.time_series return self._time_series
def __getattr__(self, name): # First checking to see if we're entering a recursion # cycle, and if so exiting immediately. Calling `hasattr(self, name)` # will call getattr(self, name) itself and therefore keep recursing. if '__getattr__' in inspect.stack()[1]: raise AttributeNotFoundException from mapmyfitness import MapMyFitness instance = MapMyFitness.instance() user = instance.user.find(self.id) self.__init__(user.original_dict) return getattr(self, name)
def test_MapMyFitness_instance(self): MapMyFitness('api-key', 'access_token') assert MapMyFitness.instance()
def get_friends(self): from mapmyfitness import MapMyFitness instance = MapMyFitness.instance() friends = instance.user.search(friends_with=self.id) return friends