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

Source Code for Module sabx10.utils.sabx_seg_reverse

 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 reversing segments in SABX files. 
23  """ 
24   
25  from sabx10.templating import SabxProcessor 
26   
27 -class RevProcessor(SabxProcessor):
28 """ 29 Process an SABX 1.0 file and reverse the order of the waypoints in a 30 segment. 31 32 @ivar seg: id of segment to reverse 33 @type seg: C{string} 34 """ 35
36 - def __init__(self, template_file=None, man=None):
37 """ 38 Add C{optparse} options for the usage. 39 40 @param template_file: (optional) file name of template file 41 @type template_file: C{string} 42 @param man: (optional) extended program help 43 @type man: C{string} 44 """ 45 SabxProcessor.__init__(self, template_file, man) 46 self.parser.usage = "%s seg_id" % self.parser.usage
47
48 - def process_options(self):
49 """ 50 Get the seg id. It's expected to be the last command-line argument. 51 """ 52 SabxProcessor.process_options(self, 1) 53 self.seg = self.args[-1]
54
55 - def get_template_data(self):
56 """ 57 Reverse the waypoints of the designated segment. 58 """ 59 SabxProcessor.get_template_data(self) 60 self.template_data['seg_dict'][self.seg].waypoints.reverse()
61