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 Warning: do not use this library. It is unstable and most of the routines
39 here have been superceded by other libraries (e.g. rospkg). These
40 routines will likely be *deleted* in future releases.
41 """
42
43 import os
44
45 import roslib.manifestlib
46
47 from roslib.manifestlib import ManifestException
48 from roslib.manifestlib import StackDepend
49
50 STACK_FILE = 'stack.xml'
51
52
54 """
55 Object representation of a ROS manifest file
56 """
57 __slots__ = []
58
60 """
61 Create an empty stack manifest instance.
62 """
63 super(StackManifest, self).__init__('stack')
64
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:
86 if required:
87 raise
88
89
91 """
92 @param stack: stack name
93 @type stack: str
94 @param required: require that the directory exist
95 @type required: bool
96 @return: path to manifest file of stack
97 @rtype: str
98 @raise InvalidROSPkgException: if required is True and manifest file cannot be located
99 """
100 d = roslib.stacks.get_stack_dir(stack)
101 return _stack_file_by_dir(d, required)
102
103
105 """
106 Parse stack.xml file
107 @param file: stack.xml file path
108 @param file: str
109 @return: StackManifest instance
110 @rtype: L{StackManifest}
111 """
112 return roslib.manifestlib.parse_file(StackManifest(), file)
113
114
115 -def parse(string, filename='string'):
116 """
117 Parse stack.xml string contents
118 @param string: stack.xml contents
119 @type string: str
120 @return: StackManifest instance
121 @rtype: L{StackManifest}
122 """
123 s = roslib.manifestlib.parse(StackManifest(), string, filename)
124
125 return s
126