Skip to content

Commit

Permalink
avg and max cadence added
Browse files Browse the repository at this point in the history
  • Loading branch information
firefly-cpp committed Jan 3, 2018
1 parent bfa6471 commit 030a3e2
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions tcxparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ def altitude_points(self):

def time_values(self):
return [x.text for x in self.root.xpath('//ns:Time', namespaces={'ns': namespace})]


def cadence_values(self):
return [int(x.text) for x in self.root.xpath('//ns:Cadence', namespaces={'ns': namespace})]

@property
def latitude(self):
if hasattr(self.activity.Lap.Track.Trackpoint, 'Position'):
Expand All @@ -39,7 +42,11 @@ def activity_type(self):
@property
def completed_at(self):
return self.activity.Lap[-1].Track.Trackpoint[-1].Time.pyval


@property
def cadence_avg(self):
return self.activity.Lap[-1].Cadence

@property
def distance(self):
distance_values = self.root.findall('.//ns:DistanceMeters', namespaces={'ns': namespace})
Expand All @@ -59,7 +66,7 @@ def duration(self):
@property
def calories(self):
return sum(lap.Calories for lap in self.activity.Lap)

@property
def hr_avg(self):
"""Average heart rate of the workout"""
Expand Down Expand Up @@ -121,3 +128,9 @@ def descent(self):
if diff < 0.0:
total_descent += abs(diff)
return total_descent

@property
def cadence_max(self):
"""Returns max cadence of workout"""
cadence_data = self.cadence_values()
return max(cadence_data)

0 comments on commit 030a3e2

Please sign in to comment.