10 from datetime
import date, datetime
13 TIMESTAMP =
'timestamp_epoch'
15 HEARTRATE =
'HEARTRATE'
16 CALORIEBURN =
'CALORIEBURN'
24 csv_reader = csv.reader(workout_report)
29 csv_header = csv_reader.next()
32 for row
in csv_reader:
34 samples.setdefault(
'timestamp', []).append(float(row[csv_header.index(TIMESTAMP)]))
35 samples.setdefault(
'distance', []).append(float(row[csv_header.index(DISTANCE)]))
36 samples.setdefault(
'heart_rate', []).append(float(row[csv_header.index(HEARTRATE)]))
37 samples.setdefault(
'calories_burned', []).append(float(row[csv_header.index(CALORIEBURN)]))
40 if samples[
'timestamp']:
42 leading_timestamp = samples[
'timestamp'][0]
43 samples[
'timestamp'] = map(
lambda x: x - leading_timestamp, samples[
'timestamp'])
69 return 500.0 / (a + b * x + c * x**2 + d * x**3 + e * x**4 + f * x**5)
82 return (100.0 * w) / (48.8 + 53.8 * math.exp(-0.075 * r))
91 return round(weight / (height ** 2), 1)
102 if isinstance(start_dt, datetime):
103 start_dt = start_dt.date()
105 dt = start_dt.replace(year=today.year)
108 dt = start_dt.replace(year=today.year, day=start_dt.day-1)
110 return today.year - start_dt.year - 1
112 return today.year - start_dt.year
123 for name, cls
in inspect.getmembers(module):
124 if inspect.isclass(cls)
and issubclass(cls, base):
125 if not with_base
and cls
is base:
127 subclasses.append(cls)
137 for line
in cslist.splitlines():
138 for item
in line.split(
','):
139 item.strip()
and items.append(item.strip())
144 return datetime.utcnow()
153 timezone = timezone
or settings.timezone
154 return times.to_local(dt, timezone)
163 timezone = timezone
or settings.timezone
164 return times.to_universal(dt, timezone)
172 days, hours, minutes = td.days, td.seconds // 3600, (td.seconds // 60) % 60
173 return Storage(days=days, hours=hours, minutes=minutes)
184 if key.startswith(prefix):
185 data[key.replace(prefix,
'')] = settings[key]
198 except KeyError
as e:
199 raise AttributeError(e)
207 except KeyError
as e:
208 raise AttributeError(e)