Attributes¶
Attribute types used for the model.
The types system provides a mechanism for serializing/un the data to/from JSON structures and for capturing additional information about the model attributes.
- class stravalib.attributes.Attribute(type_, resource_states=None, units=None)[source]¶
Bases:
objectBase descriptor class for a Strava model attribute.
- property type¶
- marshal(v)[source]¶
Turn this value into format for wire (JSON).
(By default this will just return the underlying object; subclasses can override for specific behaviors – e.g. date formatting.)
- unmarshal(v)[source]¶
Convert the value from parsed JSON structure to native python representation.
By default this will leave the value as-is since the JSON parsing routines typically convert to native types. The exception may be date strings or other more complex types, where subclasses will override this behavior.
- class stravalib.attributes.DateAttribute(resource_states=None)[source]¶
Bases:
stravalib.attributes.Attribute- unmarshal(v)[source]¶
Convert a date in “2012-12-13” format to a
datetime.dateobject.
- class stravalib.attributes.TimestampAttribute(resource_states=None, tzinfo=<UTC>)[source]¶
- class stravalib.attributes.LatLon(lat, lon)¶
Bases:
tuple- lat¶
Alias for field number 0
- lon¶
Alias for field number 1
- class stravalib.attributes.LocationAttribute(resource_states=None)[source]¶
- class stravalib.attributes.TimezoneAttribute(resource_states=None)[source]¶
- class stravalib.attributes.TimeIntervalAttribute(resource_states=None)[source]¶
Bases:
stravalib.attributes.AttributeHandles time durations, assumes upstream int value in seconds.
- unmarshal(v)[source]¶
Convert the value from parsed JSON structure to native python representation.
By default this will leave the value as-is since the JSON parsing routines typically convert to native types. The exception may be date strings or other more complex types, where subclasses will override this behavior.
- class stravalib.attributes.ChoicesAttribute(*args, **kwargs)[source]¶
Bases:
stravalib.attributes.AttributeAttribute where there are several choices the attribute may take.
Allows conversion from the API value to a more helpful python value.
- class stravalib.attributes.EntityAttribute(*args, **kwargs)[source]¶
Bases:
stravalib.attributes.AttributeAttribute for another entity.
- property type¶
- marshal(v)[source]¶
Turn an entity into a dictionary.
- Parameters
v (stravalib.model.BaseEntity) – The entity to serialize.
- Returns
Dictionary of attributes
- Return type
Dict[str, Any]
- class stravalib.attributes.EntityCollection(*args, **kwargs)[source]¶
Bases:
stravalib.attributes.EntityAttribute- marshal(values)[source]¶
Turn a list of entities into a list of dictionaries.
- Parameters
values (List[stravalib.model.BaseEntity]) – The entities to serialize.
- Returns
List of dictionaries of attributes
- Return type
List[Dict[str, Any]]