Package sabx10 :: Package utils :: Module sabx2html
[hide private]
[frames] | no frames]

Source Code for Module sabx10.utils.sabx2html

 1  ############################################################################### 
 2  # 
 3  # sabx10 - an SABX file manipulation library 
 4  # Copyright (C) 2009, 2010 Jay Farrimond (jay@sabikerides.com) 
 5  # 
 6  # This file is part of sabx10. 
 7  # 
 8  # sabx10 is free software: you can redistribute it and/or modify it under the 
 9  # terms of the GNU General Public License as published by the Free Software 
10  # Foundation, either version 3 of the License, or (at your option) any later 
11  # version. 
12  # 
13  # sabx10 is distributed in the hope that it will be useful, but WITHOUT ANY 
14  # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 
15  # A PARTICULAR PURPOSE.  See the GNU General Public License for more details. 
16  # 
17  # You should have received a copy of the GNU General Public License along with 
18  # sabx10.  If not, see <http://www.gnu.org/licenses/>. 
19  # 
20  ############################################################################### 
21  """ 
22  Handle converting SABX point data into a basic HTML file. 
23  """ 
24   
25  from sabx10.oxm import parse_no_def_namespaces, parse_tree 
26  from sabx10.templating import SabxProcessor 
27   
28 -class HtmlProcessor(SabxProcessor):
29 """ 30 Process an SABX 1.0 file, pulling out all its point data for processing. 31 """ 32
33 - def __init__(self, template_file=None, man=None):
34 """ 35 Add C{optparse} options for the index. 36 37 @param template_file: (optional) file name of template file 38 @type template_file: C{string} 39 @param man: (optional) extended program help 40 @type man: C{string} 41 """ 42 SabxProcessor.__init__(self, template_file, man) 43 44 self.parser.add_option("-n", "--index", dest="ride_index", 45 default="1", 46 help="ride index")
47
48 - def get_template_data(self):
49 """ 50 Add the points to the SABX 1.0 data. 51 """ 52 SabxProcessor.get_template_data(self) 53 54 points = [] 55 for seg_id in \ 56 self.template_data['ride_dict'][self.options.ride_index].segs: 57 for pt in self.template_data['seg_dict'][seg_id].waypoints: 58 points.append( {'index': pt.id, 59 'lat': pt.lat, 60 'lon': pt.lon, 61 'ele': pt.ele} ) 62 self.template_data['points'] = points
63