key / bicicalc

cyclo computer data cliculator (Garmin, Polar, PowerTap etc)

This URL has Read+Write access

bicicalc / g_userprofile.py
100755 41 lines (30 sloc) 1.099 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from optparse import OptionParser
from Bicicalc.Garmin.Tcx import userprofile
 
def main():
    parser = OptionParser()
    parser.need_dump = False
    (options, args) = parser.parse_args()
 
    if len(args) < 1:
        raise Exception('Please set UserProfile.tcx file')
    data=userprofile.parseString(args[0])
 
    print_summary(data)
 
 
def print_summary(data):
    print 'UserProfile'
 
    print 'BirthDate:\t' + data['birthdate']
    print 'Gender:\t\t' + data['gender']
    print 'Weight:\t\t%.1fkg' % (data['weight'])
    print 'MaximumHR:\t' + str(data['heartrate_max'])
    print 'GearWeight:\t%.2fkg' % (data['gearweight'])
    print 'FTP:\t\t%dWatts' % (data['ftp'])
 
    print ''
    print '\t\t\tLow\tHigh'
 
    for hrz in data['heartrate_zones']:
        print 'HeartRate Zone %d:\t%d\t%d' % (hrz['number'], hrz['low'], hrz['high'])
 
    print ''
    print '\t\t\tLow\tHigh'
    for pwrz in data['power_zones']:
        print 'Power Zone %d:\t\t%d\t%d' % (pwrz['number'], pwrz['low'], pwrz['high'])
 
if __name__ == '__main__':
    main()