How to use the stravalib.attributes.EntityAttribute 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 / model.py View on Github external
elapsed_time = TimeIntervalAttribute()  #: :class:`datetime.timedelta` of total elapsed time
    elevation_gain = Attribute(float, units=uh.meters)  #: Total elevation gain
    moving_time = TimeIntervalAttribute()  #: :class:`datetime.timedelta` of total moving time


class AthleteStats(BaseEntity):
    """
    Represents a combined set of an Athlete's statistics.
    """
    biggest_ride_distance = Attribute(float, units=uh.meters)  #: Longest ride for athlete.
    biggest_climb_elevation_gain = Attribute(float, units=uh.meters)  #: Greatest single elevation gain for athlete.
    recent_ride_totals = EntityAttribute(ActivityTotals)  #: Recent totals for rides. (:class:`stravalib.model.ActivityTotals`)
    recent_run_totals = EntityAttribute(ActivityTotals)  #: Recent totals for runs. (:class:`stravalib.model.ActivityTotals`)
    recent_swim_totals = EntityAttribute(ActivityTotals)  #: Recent totals for swims. (:class:`stravalib.model.ActivityTotals`)
    ytd_ride_totals = EntityAttribute(ActivityTotals)  #: Year-to-date totals for rides. (:class:`stravalib.model.ActivityTotals`)
    ytd_run_totals = EntityAttribute(ActivityTotals)  #: Year-to-date totals for runs. (:class:`stravalib.model.ActivityTotals`)
    ytd_swim_totals = EntityAttribute(ActivityTotals)  #: Year-to-date totals for swims. (:class:`stravalib.model.ActivityTotals`)
    all_ride_totals = EntityAttribute(ActivityTotals)  #: All-time totals for rides. (:class:`stravalib.model.ActivityTotals`)
    all_run_totals = EntityAttribute(ActivityTotals)  #: All-time totals for runs. (:class:`stravalib.model.ActivityTotals`)
    all_swim_totals = EntityAttribute(ActivityTotals)  #: All-time totals for swims. (:class:`stravalib.model.ActivityTotals`)


class Athlete(LoadableEntity):
    """
    Represents a Strava athlete.
    """
    firstname = Attribute(six.text_type, (SUMMARY, DETAILED))  #: Athlete's first name.
    lastname = Attribute(six.text_type, (SUMMARY, DETAILED))  #: Athlete's last name.
    profile_medium = Attribute(six.text_type, (SUMMARY, DETAILED))  #: URL to a 62x62 pixel profile picture
    profile = Attribute(six.text_type, (SUMMARY, DETAILED))  #: URL to a 124x124 pixel profile picture
    city = Attribute(six.text_type, (SUMMARY, DETAILED))  #: Athlete's home city
    state = Attribute(six.text_type, (SUMMARY, DETAILED))  #: Athlete's home state
github hozn / stravalib / stravalib / model.py View on Github external
end_longitude = Attribute(float, (SUMMARY, DETAILED))  #: The end longitude (:class:`float`)
    climb_category = Attribute(int, (SUMMARY, DETAILED))  # 0-5, lower is harder
    city = Attribute(six.text_type, (SUMMARY, DETAILED))  #: The city this segment is in.
    state = Attribute(six.text_type, (SUMMARY, DETAILED))  #: The state this segment is in.
    country = Attribute(six.text_type, (SUMMARY, DETAILED))  #: The country this segment is in.
    private = Attribute(bool, (SUMMARY, DETAILED))  #: Whether this is a private segment.
    starred = Attribute(bool, (SUMMARY, DETAILED))  #: Whether this segment is starred by authenticated athlete

    athlete_segment_stats = EntityAttribute(AthleteSegmentStats, (DETAILED,)) #: Undocumented attrib holding stats for current athlete.

    # detailed attribs
    created_at = TimestampAttribute((DETAILED,))  #: :class:`datetime.datetime` when was segment created.
    updated_at = TimestampAttribute((DETAILED,))  #: :class:`datetime.datetime` when was segment last updated.
    total_elevation_gain = Attribute(float, (DETAILED,), units=uh.meters)  #: What is total elevation gain for segment.
    map = EntityAttribute(Map, (DETAILED,))  #: :class:`stravalib.model.Map` object for segment.
    effort_count = Attribute(int, (DETAILED,))  #: How many times has this segment been ridden.
    athlete_count = Attribute(int, (DETAILED,))  #: How many athletes have ridden this segment
    hazardous = Attribute(bool, (DETAILED,))  #: Whether this segment has been flagged as hazardous
    star_count = Attribute(int, (DETAILED,))  #: number of stars on this segment.
    pr_time = Attribute(int, (DETAILED,)) #: pr time for athlete
    starred_date = TimestampAttribute((DETAILED, )) #: datetime when be starred
    athlete_pr_effort = EntityAttribute(AthletePrEffort, (DETAILED,))

    @property
    def leaderboard(self):
        """
        The :class:`stravalib.model.SegmentLeaderboard` object for this segment.
        """
        if self._leaderboard is None:
            self.assert_bind_client()
            if self.id is not None:
github hozn / stravalib / stravalib / model.py View on Github external
count = Attribute(int)  #: How many activities
    distance = Attribute(float, units=uh.meters)  #: Total distance travelled
    elapsed_time = TimeIntervalAttribute()  #: :class:`datetime.timedelta` of total elapsed time
    elevation_gain = Attribute(float, units=uh.meters)  #: Total elevation gain
    moving_time = TimeIntervalAttribute()  #: :class:`datetime.timedelta` of total moving time


class AthleteStats(BaseEntity):
    """
    Represents a combined set of an Athlete's statistics.
    """
    biggest_ride_distance = Attribute(float, units=uh.meters)  #: Longest ride for athlete.
    biggest_climb_elevation_gain = Attribute(float, units=uh.meters)  #: Greatest single elevation gain for athlete.
    recent_ride_totals = EntityAttribute(ActivityTotals)  #: Recent totals for rides. (:class:`stravalib.model.ActivityTotals`)
    recent_run_totals = EntityAttribute(ActivityTotals)  #: Recent totals for runs. (:class:`stravalib.model.ActivityTotals`)
    recent_swim_totals = EntityAttribute(ActivityTotals)  #: Recent totals for swims. (:class:`stravalib.model.ActivityTotals`)
    ytd_ride_totals = EntityAttribute(ActivityTotals)  #: Year-to-date totals for rides. (:class:`stravalib.model.ActivityTotals`)
    ytd_run_totals = EntityAttribute(ActivityTotals)  #: Year-to-date totals for runs. (:class:`stravalib.model.ActivityTotals`)
    ytd_swim_totals = EntityAttribute(ActivityTotals)  #: Year-to-date totals for swims. (:class:`stravalib.model.ActivityTotals`)
    all_ride_totals = EntityAttribute(ActivityTotals)  #: All-time totals for rides. (:class:`stravalib.model.ActivityTotals`)
    all_run_totals = EntityAttribute(ActivityTotals)  #: All-time totals for runs. (:class:`stravalib.model.ActivityTotals`)
    all_swim_totals = EntityAttribute(ActivityTotals)  #: All-time totals for swims. (:class:`stravalib.model.ActivityTotals`)


class Athlete(LoadableEntity):
    """
    Represents a Strava athlete.
    """
    firstname = Attribute(six.text_type, (SUMMARY, DETAILED))  #: Athlete's first name.
    lastname = Attribute(six.text_type, (SUMMARY, DETAILED))  #: Athlete's last name.
    profile_medium = Attribute(six.text_type, (SUMMARY, DETAILED))  #: URL to a 62x62 pixel profile picture
    profile = Attribute(six.text_type, (SUMMARY, DETAILED))  #: URL to a 124x124 pixel profile picture
github hozn / stravalib / stravalib / attributes.py View on Github external
def __init__(self, *args, **kwargs):
        super(EntityAttribute, self).__init__(*args, **kwargs)
        self.bind_clients = WeakKeyDictionary()
github hozn / stravalib / stravalib / model.py View on Github external
achievement_count = Attribute(int)  #: How many achievements
    count = Attribute(int)  #: How many activities
    distance = Attribute(float, units=uh.meters)  #: Total distance travelled
    elapsed_time = TimeIntervalAttribute()  #: :class:`datetime.timedelta` of total elapsed time
    elevation_gain = Attribute(float, units=uh.meters)  #: Total elevation gain
    moving_time = TimeIntervalAttribute()  #: :class:`datetime.timedelta` of total moving time


class AthleteStats(BaseEntity):
    """
    Represents a combined set of an Athlete's statistics.
    """
    biggest_ride_distance = Attribute(float, units=uh.meters)  #: Longest ride for athlete.
    biggest_climb_elevation_gain = Attribute(float, units=uh.meters)  #: Greatest single elevation gain for athlete.
    recent_ride_totals = EntityAttribute(ActivityTotals)  #: Recent totals for rides. (:class:`stravalib.model.ActivityTotals`)
    recent_run_totals = EntityAttribute(ActivityTotals)  #: Recent totals for runs. (:class:`stravalib.model.ActivityTotals`)
    recent_swim_totals = EntityAttribute(ActivityTotals)  #: Recent totals for swims. (:class:`stravalib.model.ActivityTotals`)
    ytd_ride_totals = EntityAttribute(ActivityTotals)  #: Year-to-date totals for rides. (:class:`stravalib.model.ActivityTotals`)
    ytd_run_totals = EntityAttribute(ActivityTotals)  #: Year-to-date totals for runs. (:class:`stravalib.model.ActivityTotals`)
    ytd_swim_totals = EntityAttribute(ActivityTotals)  #: Year-to-date totals for swims. (:class:`stravalib.model.ActivityTotals`)
    all_ride_totals = EntityAttribute(ActivityTotals)  #: All-time totals for rides. (:class:`stravalib.model.ActivityTotals`)
    all_run_totals = EntityAttribute(ActivityTotals)  #: All-time totals for runs. (:class:`stravalib.model.ActivityTotals`)
    all_swim_totals = EntityAttribute(ActivityTotals)  #: All-time totals for swims. (:class:`stravalib.model.ActivityTotals`)


class Athlete(LoadableEntity):
    """
    Represents a Strava athlete.
    """
    firstname = Attribute(six.text_type, (SUMMARY, DETAILED))  #: Athlete's first name.
    lastname = Attribute(six.text_type, (SUMMARY, DETAILED))  #: Athlete's last name.
    profile_medium = Attribute(six.text_type, (SUMMARY, DETAILED))  #: URL to a 62x62 pixel profile picture
github hozn / stravalib / stravalib / model.py View on Github external
"""
    A primary photo attached to an activity (different structure from full photo record)
    """
    id = Attribute(int, (META, SUMMARY, DETAILED))  #: ID of photo, if external.
    unique_id = Attribute(six.text_type, (META, SUMMARY, DETAILED))  #: ID of photo, if internal.
    urls = Attribute(dict, (META, SUMMARY, DETAILED))
    source = Attribute(int, (META, SUMMARY, DETAILED))  #: 1=internal, 2=instagram
    use_primary_photo = Attribute(bool,(META, SUMMARY, DETAILED))  #: (undocumented)


class ActivityPhotoMeta(BaseEntity):
    """
    The photos structure returned with the activity, not to be confused with the full loaded photos for an activity.
    """
    count = Attribute(int, (META, SUMMARY, DETAILED))
    primary = EntityAttribute(ActivityPhotoPrimary, (META, SUMMARY, DETAILED))
    use_primary_photo = Attribute(bool, (META, SUMMARY, DETAILED))

    def __repr__(self):
        return '<{0} count={1}>'.format(self.__class__.__name__, self.count)


class ActivityPhoto(LoadableEntity):
    """
    A full photo record attached to an activity.
    """
    athlete_id = Attribute(int, (META, SUMMARY, DETAILED))  #: ID of athlete
    activity_id = Attribute(int, (META, SUMMARY, DETAILED))  #: ID of activity
    activity_name = Attribute(six.text_type, (META, SUMMARY, DETAILED))  #: Name of activity.
    ref = Attribute(six.text_type, (META, SUMMARY, DETAILED))  #: ref eg. "http://instagram.com/p/eAvA-tir85/"

    uid = Attribute(six.text_type, (META, SUMMARY, DETAILED))  #: unique id for instagram photo
github hozn / stravalib / stravalib / model.py View on Github external
elevation_low = Attribute(float, (SUMMARY, DETAILED), units=uh.meters)  #: The lowest point of the segment.
    start_latlng = LocationAttribute((SUMMARY, DETAILED))  #: The start lat/lon (:class:`tuple`)
    end_latlng = LocationAttribute((SUMMARY, DETAILED))  #: The end lat/lon (:class:`tuple`)
    start_latitude = Attribute(float, (SUMMARY, DETAILED))  #: The start latitude (:class:`float`)
    end_latitude = Attribute(float, (SUMMARY, DETAILED))  #: The end latitude (:class:`float`)
    start_longitude = Attribute(float, (SUMMARY, DETAILED))  #: The start longitude (:class:`float`)

    end_longitude = Attribute(float, (SUMMARY, DETAILED))  #: The end longitude (:class:`float`)
    climb_category = Attribute(int, (SUMMARY, DETAILED))  # 0-5, lower is harder
    city = Attribute(six.text_type, (SUMMARY, DETAILED))  #: The city this segment is in.
    state = Attribute(six.text_type, (SUMMARY, DETAILED))  #: The state this segment is in.
    country = Attribute(six.text_type, (SUMMARY, DETAILED))  #: The country this segment is in.
    private = Attribute(bool, (SUMMARY, DETAILED))  #: Whether this is a private segment.
    starred = Attribute(bool, (SUMMARY, DETAILED))  #: Whether this segment is starred by authenticated athlete

    athlete_segment_stats = EntityAttribute(AthleteSegmentStats, (DETAILED,)) #: Undocumented attrib holding stats for current athlete.

    # detailed attribs
    created_at = TimestampAttribute((DETAILED,))  #: :class:`datetime.datetime` when was segment created.
    updated_at = TimestampAttribute((DETAILED,))  #: :class:`datetime.datetime` when was segment last updated.
    total_elevation_gain = Attribute(float, (DETAILED,), units=uh.meters)  #: What is total elevation gain for segment.
    map = EntityAttribute(Map, (DETAILED,))  #: :class:`stravalib.model.Map` object for segment.
    effort_count = Attribute(int, (DETAILED,))  #: How many times has this segment been ridden.
    athlete_count = Attribute(int, (DETAILED,))  #: How many athletes have ridden this segment
    hazardous = Attribute(bool, (DETAILED,))  #: Whether this segment has been flagged as hazardous
    star_count = Attribute(int, (DETAILED,))  #: number of stars on this segment.
    pr_time = Attribute(int, (DETAILED,)) #: pr time for athlete
    starred_date = TimestampAttribute((DETAILED, )) #: datetime when be starred
    athlete_pr_effort = EntityAttribute(AthletePrEffort, (DETAILED,))

    @property
    def leaderboard(self):
github hozn / stravalib / stravalib / model.py View on Github external
class AthleteStats(BaseEntity):
    """
    Represents a combined set of an Athlete's statistics.
    """
    biggest_ride_distance = Attribute(float, units=uh.meters)  #: Longest ride for athlete.
    biggest_climb_elevation_gain = Attribute(float, units=uh.meters)  #: Greatest single elevation gain for athlete.
    recent_ride_totals = EntityAttribute(ActivityTotals)  #: Recent totals for rides. (:class:`stravalib.model.ActivityTotals`)
    recent_run_totals = EntityAttribute(ActivityTotals)  #: Recent totals for runs. (:class:`stravalib.model.ActivityTotals`)
    recent_swim_totals = EntityAttribute(ActivityTotals)  #: Recent totals for swims. (:class:`stravalib.model.ActivityTotals`)
    ytd_ride_totals = EntityAttribute(ActivityTotals)  #: Year-to-date totals for rides. (:class:`stravalib.model.ActivityTotals`)
    ytd_run_totals = EntityAttribute(ActivityTotals)  #: Year-to-date totals for runs. (:class:`stravalib.model.ActivityTotals`)
    ytd_swim_totals = EntityAttribute(ActivityTotals)  #: Year-to-date totals for swims. (:class:`stravalib.model.ActivityTotals`)
    all_ride_totals = EntityAttribute(ActivityTotals)  #: All-time totals for rides. (:class:`stravalib.model.ActivityTotals`)
    all_run_totals = EntityAttribute(ActivityTotals)  #: All-time totals for runs. (:class:`stravalib.model.ActivityTotals`)
    all_swim_totals = EntityAttribute(ActivityTotals)  #: All-time totals for swims. (:class:`stravalib.model.ActivityTotals`)


class Athlete(LoadableEntity):
    """
    Represents a Strava athlete.
    """
    firstname = Attribute(six.text_type, (SUMMARY, DETAILED))  #: Athlete's first name.
    lastname = Attribute(six.text_type, (SUMMARY, DETAILED))  #: Athlete's last name.
    profile_medium = Attribute(six.text_type, (SUMMARY, DETAILED))  #: URL to a 62x62 pixel profile picture
    profile = Attribute(six.text_type, (SUMMARY, DETAILED))  #: URL to a 124x124 pixel profile picture
    city = Attribute(six.text_type, (SUMMARY, DETAILED))  #: Athlete's home city
    state = Attribute(six.text_type, (SUMMARY, DETAILED))  #: Athlete's home state
    country = Attribute(six.text_type, (SUMMARY, DETAILED))  #: Athlete's home country
    sex = Attribute(six.text_type, (SUMMARY, DETAILED))  #: Athlete's sex ('M', 'F' or null)
    friend = Attribute(six.text_type, (SUMMARY, DETAILED))  #: 'pending', 'accepted', 'blocked' or 'null' the authenticated athlete's following status of this athlete
    follower = Attribute(six.text_type, (SUMMARY, DETAILED))  #: 'pending', 'accepted', 'blocked' or 'null' this athlete's following status of the authenticated athlete
github hozn / stravalib / stravalib / model.py View on Github external
pr_count = Attribute(int, (SUMMARY, DETAILED))  #: How many new personal records earned for the activity
    kudos_count = Attribute(int, (SUMMARY, DETAILED))  #: How many kudos received for activity
    comment_count = Attribute(int, (SUMMARY, DETAILED))  #: How many comments  for activity.
    athlete_count = Attribute(int, (SUMMARY, DETAILED))  #: How many other athlete's participated in activity
    photo_count = Attribute(int, (SUMMARY, DETAILED))  #: Number of Instagram photos
    total_photo_count = Attribute(int, (SUMMARY, DETAILED))  #: Total number of photos (Instagram and Strava)
    map = EntityAttribute(Map, (SUMMARY, DETAILED))  #: :class:`stravavlib.model.Map` of activity.

    trainer = Attribute(bool, (SUMMARY, DETAILED))  #: Whether activity was performed on a stationary trainer.
    commute = Attribute(bool, (SUMMARY, DETAILED))  #: Whether activity is a commute.
    manual = Attribute(bool, (SUMMARY, DETAILED))  #: Whether activity was manually entered.
    private = Attribute(bool, (SUMMARY, DETAILED))  #: Whether activity is private
    flagged = Attribute(bool, (SUMMARY, DETAILED))   #: Whether activity was flagged.

    gear_id = Attribute(six.text_type, (SUMMARY, DETAILED))  #: Which bike/shoes were used on activity.
    gear = EntityAttribute(Gear, (DETAILED,))

    average_speed = Attribute(float, (SUMMARY, DETAILED), units=uh.meters_per_second)  #: Average speed for activity.
    max_speed = Attribute(float, (SUMMARY, DETAILED), units=uh.meters_per_second)  #: Max speed for activity

    device_watts = Attribute(bool, (SUMMARY, DETAILED))  #: True if the watts are from a power meter, false if estimated

    has_kudoed = Attribute(bool, (SUMMARY, DETAILED))  #: If authenticated user has kudoed this activity

    best_efforts = EntityCollection(BestEffort, (DETAILED,))  #: :class:`list` of metric :class:`stravalib.model.BestEffort` summaries
    segment_efforts = EntityCollection(SegmentEffort, (DETAILED,))  #: :class:`list` of :class:`stravalib.model.SegmentEffort` efforts for activity.
    splits_metric = EntityCollection(Split, (DETAILED,))  #: :class:`list` of metric :class:`stravalib.model.Split` summaries (running activities only)
    splits_standard = EntityCollection(Split, (DETAILED,))  #: :class:`list` of standard/imperial :class:`stravalib.model.Split` summaries (running activities only)

    average_watts = Attribute(float, (SUMMARY, DETAILED))  #: (undocumented) Average power during activity
    weighted_average_watts = Attribute(int, (SUMMARY, DETAILED))  # rides with power meter data only similar to xPower or Normalized Power
    max_watts = Attribute(int, (SUMMARY, DETAILED))  #: rides with power meter data only
github hozn / stravalib / stravalib / model.py View on Github external
elevation_gain = Attribute(float, units=uh.meters)  #: Total elevation gain
    moving_time = TimeIntervalAttribute()  #: :class:`datetime.timedelta` of total moving time


class AthleteStats(BaseEntity):
    """
    Represents a combined set of an Athlete's statistics.
    """
    biggest_ride_distance = Attribute(float, units=uh.meters)  #: Longest ride for athlete.
    biggest_climb_elevation_gain = Attribute(float, units=uh.meters)  #: Greatest single elevation gain for athlete.
    recent_ride_totals = EntityAttribute(ActivityTotals)  #: Recent totals for rides. (:class:`stravalib.model.ActivityTotals`)
    recent_run_totals = EntityAttribute(ActivityTotals)  #: Recent totals for runs. (:class:`stravalib.model.ActivityTotals`)
    recent_swim_totals = EntityAttribute(ActivityTotals)  #: Recent totals for swims. (:class:`stravalib.model.ActivityTotals`)
    ytd_ride_totals = EntityAttribute(ActivityTotals)  #: Year-to-date totals for rides. (:class:`stravalib.model.ActivityTotals`)
    ytd_run_totals = EntityAttribute(ActivityTotals)  #: Year-to-date totals for runs. (:class:`stravalib.model.ActivityTotals`)
    ytd_swim_totals = EntityAttribute(ActivityTotals)  #: Year-to-date totals for swims. (:class:`stravalib.model.ActivityTotals`)
    all_ride_totals = EntityAttribute(ActivityTotals)  #: All-time totals for rides. (:class:`stravalib.model.ActivityTotals`)
    all_run_totals = EntityAttribute(ActivityTotals)  #: All-time totals for runs. (:class:`stravalib.model.ActivityTotals`)
    all_swim_totals = EntityAttribute(ActivityTotals)  #: All-time totals for swims. (:class:`stravalib.model.ActivityTotals`)


class Athlete(LoadableEntity):
    """
    Represents a Strava athlete.
    """
    firstname = Attribute(six.text_type, (SUMMARY, DETAILED))  #: Athlete's first name.
    lastname = Attribute(six.text_type, (SUMMARY, DETAILED))  #: Athlete's last name.
    profile_medium = Attribute(six.text_type, (SUMMARY, DETAILED))  #: URL to a 62x62 pixel profile picture
    profile = Attribute(six.text_type, (SUMMARY, DETAILED))  #: URL to a 124x124 pixel profile picture
    city = Attribute(six.text_type, (SUMMARY, DETAILED))  #: Athlete's home city
    state = Attribute(six.text_type, (SUMMARY, DETAILED))  #: Athlete's home state
    country = Attribute(six.text_type, (SUMMARY, DETAILED))  #: Athlete's home country