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