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 Python parser for rospack stack.xml files. See U{http://pr.willowgarage.com/wiki/Stack%20Manifest}
39 """
40
41 import sys
42 import os
43 import getopt
44
45 import roslib.exceptions
46 import roslib.packages
47 import roslib.rosenv
48
49 STACK_FILE = 'stack.xml'
50
51 import roslib.manifestlib
52
53 from roslib.manifestlib import ManifestException, StackDepend
54
56 """
57 Object representation of a ROS manifest file
58 """
59 __slots__ = []
61 """
62 Create an empty stack manifest instance.
63 """
64 super(StackManifest, self).__init__('stack')
65
67 """
68 @param stack_dir: path to stack directory
69 @type stack_dir: str
70 @param required: require that the directory exist
71 @type required: bool
72 @return: path to manifest file of stack
73 @rtype: str
74 @raise InvalidROSPkgException: if required is True and manifest file cannot be located
75 """
76 try:
77 p = os.path.join(stack_dir, STACK_FILE)
78 if not required and not os.path.exists(p):
79 return p
80 if not os.path.isfile(p):
81 raise roslib.stacks.InvalidROSStackException("""
82 Stack '%(stack_dir)s' is improperly configured: no manifest file is present.
83 """%locals())
84 return p
85 except roslib.stacks.InvalidROSStackException as e:
86 if required:
87 raise
88
90 """
91 @param stack: stack name
92 @type stack: str
93 @param required: require that the directory exist
94 @type required: bool
95 @return: path to manifest file of stack
96 @rtype: str
97 @raise InvalidROSPkgException: if required is True and manifest file cannot be located
98 """
99 d = roslib.stacks.get_stack_dir(stack)
100 return _stack_file_by_dir(d, required)
101
103 """
104 Parse stack.xml file
105 @param file: stack.xml file path
106 @param file: str
107 @return: StackManifest instance
108 @rtype: L{StackManifest}
109 """
110 return roslib.manifestlib.parse_file(StackManifest(), file)
111
112 -def parse(string, filename='string'):
113 """
114 Parse stack.xml string contents
115 @param string: stack.xml contents
116 @type string: str
117 @return: StackManifest instance
118 @rtype: L{StackManifest}
119 """
120 s = roslib.manifestlib.parse(StackManifest(), string, filename)
121
122 return s
123