How to use the stravalib.model.Athlete function in stravalib

To help you get started, we’ve selected a few stravalib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hozn / stravalib / stravalib / client.py View on Github external
http://strava.github.io/api/v3/athlete/#get-details

        http://strava.github.io/api/v3/athlete/#get-another-details

        :return: The athlete model object.
        :rtype: :class:`stravalib.model.Athlete`
        """
        if athlete_id is None:
            raw = self.protocol.get('/athlete')
        else:
            raise NotImplementedError("The /athletes/{id} endpoint was removed by Strava.  "
                                      "See https://developers.strava.com/docs/january-2018-update/")

            # raw = self.protocol.get('/athletes/{athlete_id}', athlete_id=athlete_id)

        return model.Athlete.deserialize(raw, bind_client=self)
github hozn / stravalib / stravalib / protocol / v1.py View on Github external
def populate_ride_effort_base(self, entity_model, entity_struct):
        """
        Populates the attributes shared by rides and efforts.
        """
        self.populate_minimal(entity_model, entity_struct)
        
        athlete_struct = entity_struct['athlete']
        athlete = Athlete(bind_client=entity_model.bind_client)
        self.populate_athlete(athlete, athlete_struct)
        entity_model.athlete = athlete
        
        entity_model.average_speed = self._convert_speed(entity_struct['averageSpeed'])
        entity_model.average_watts = entity_struct['averageWatts']
        entity_model.maximum_speed = self._convert_speed(measurement.kph(entity_struct['maximumSpeed'] / 1000.0)) # Not sure why this is in meters per *hour* ... !?
        entity_model.elevation_gain = self._convert_elevation(entity_struct['elevationGain'])
        entity_model.distance = self._convert_distance(entity_struct['distance'])
        entity_model.elapsed_time = timedelta(seconds=entity_struct['elapsedTime'])
        entity_model.moving_time = timedelta(seconds=entity_struct['movingTime'])
        entity_model.start_date = self._parse_datetime(entity_struct['startDateLocal'], entity_struct['timeZoneOffset'])
github hozn / stravalib / stravalib / model.py View on Github external
"""
    An undocumented structure being returned for segment efforts.
    """
    rank = Attribute(int)  #: Rank in segment (either overall leaderboard, or pr rank)
    type = Attribute(six.text_type)  #: The type of achievement -- e.g. 'year_pr' or 'overall'
    type_id = Attribute(int)  #: Numeric ID for type of achievement?  (6 = year_pr, 2 = overall ??? other?)


class BaseEffort(LoadableEntity):
    """
    Base class for a best effort or segment effort.
    """
    name = Attribute(six.text_type, (SUMMARY, DETAILED))  #: The name of the segment
    segment = EntityAttribute(Segment, (SUMMARY, DETAILED))  #: The associated :class:`stravalib.model.Segment` for this effort
    activity = EntityAttribute("Activity", (SUMMARY, DETAILED))  #: The associated :class:`stravalib.model.Activity`
    athlete = EntityAttribute(Athlete, (SUMMARY, DETAILED))  #: The associated :class:`stravalib.model.Athlete`
    kom_rank = Attribute(int, (SUMMARY, DETAILED))  #: 1-10 segment KOM ranking for athlete at time of upload
    pr_rank = Attribute(int, (SUMMARY, DETAILED))  #: 1-3 personal record ranking for athlete at time of upload
    moving_time = TimeIntervalAttribute((SUMMARY, DETAILED))  #: :class:`datetime.timedelta`
    elapsed_time = TimeIntervalAttribute((SUMMARY, DETAILED))  #: :class:`datetime.timedelta`
    start_date = TimestampAttribute((SUMMARY, DETAILED))  #: :class:`datetime.datetime` when effort was started in GMT
    start_date_local = TimestampAttribute((SUMMARY, DETAILED), tzinfo=None)  #: :class:`datetime.datetime` when effort was started in activity timezone for this effort
    distance = Attribute(int, (SUMMARY, DETAILED), units=uh.meters)  #: The distance for this effort.
    average_watts = Attribute(float, (SUMMARY, DETAILED))  #: Average power during effort
    device_watts = Attribute(bool, (SUMMARY, DETAILED))  #: True if the watts are from a power meter, false if estimated
    average_heartrate = Attribute(float, (SUMMARY, DETAILED))   #: Average HR during effort
    max_heartrate = Attribute(float, (SUMMARY, DETAILED))   #: Max HR during effort
    average_cadence = Attribute(float, (SUMMARY, DETAILED))   #: Average cadence during effort
    start_index = Attribute(int, (SUMMARY, DETAILED))  #: The activity stream index of the start of this effort
    end_index = Attribute(int, (SUMMARY, DETAILED))  #: The activity stream index of the end of this effort

    achievements = EntityCollection(SegmentEfforAchievement, (SUMMARY, DETAILED))  #: Undocumented attribute includes list of achievements for this effort.
github hozn / stravalib / stravalib / protocol / v1.py View on Github external
"username": "jdickey"
                }, 
                "elapsedTime": 103, 
                "id": 13149960, 
                "startDate": "2011-07-06T21:32:21Z", 
                "startDateLocal": "2011-07-06T17:32:21Z", 
                "timeZoneOffset": -18000
            }
        :param effort_model:
        :type effort_model: :class:`stravalib.model.SegmentEffort`
        """
        effort_model.id = effort_struct['id']
        effort_model.activity_id = effort_struct['activityId']
        effort_model.elapsed_time = timedelta(seconds=effort_struct['elapsedTime'])
        effort_model.start_date = self._parse_datetime(effort_struct['startDateLocal'], effort_struct['timeZoneOffset'])
        effort_model.athlete = Athlete(self.client)
        self.populate_athlete(effort_model.athlete, effort_struct['athlete'])
github hozn / stravalib / stravalib / client.py View on Github external
:param limit: Maximum number of athletes to return (default unlimited).
        :type limit: int

        :return: An iterator of :class:`stravalib.model.Athlete` objects.
        :rtype: :class:`BatchedResultsIterator`
        """
        if athlete_id is None:
            result_fetcher = functools.partial(self.protocol.get, '/athlete/followers')
        else:
            raise NotImplementedError("The /athletes/{id}/followers endpoint was removed by Strava.  "
                                      "See https://developers.strava.com/docs/january-2018-update/")
            # result_fetcher = functools.partial(self.protocol.get,
            #                                    '/athletes/{id}/followers',
            #                                    id=athlete_id)

        return BatchedResultsIterator(entity=model.Athlete,
                                      bind_client=self,
                                      result_fetcher=result_fetcher,
                                      limit=limit)