1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 """
22 Handle reversing segments in SABX files.
23 """
24
25 from sabx10.templating import SabxProcessor
26
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
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
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