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 import roslib.packages
48
49 MANIFEST_FILE = 'manifest.xml'
50
51 import roslib.manifestlib
52
53 from roslib.manifestlib import ManifestException, Depend, Export, ROSDep, VersionControl
54
55 -class Manifest(roslib.manifestlib._Manifest):
56 """
57 Object representation of a ROS manifest file
58 """
59 __slots__ = []
61 """
62 Initialize new empty manifest.
63 """
64 super(Manifest, self).__init__('package')
65
67 """
68 @return: exports that match the specified tag and attribute, e.g. 'python', 'path'
69 @rtype: [L{Export}]
70 """
71 return [e.get(attr) for e in self.exports if e.tag == tag if e.get(attr) is not None]
72
74 """
75 @param package_dir: path to package directory
76 @type package_dir: str
77 @param env: environment dictionary
78 @type env: dict
79 @param required: require that the directory exist
80 @type required: bool
81 @return: path to manifest file of package
82 @rtype: str
83 @raise InvalidROSPkgException: if required is True and manifest file cannot be located
84 """
85 if env is None:
86 env = os.environ
87 try:
88 p = os.path.join(package_dir, MANIFEST_FILE)
89 if not required and not os.path.exists(p):
90 return p
91 if not os.path.isfile(p):
92 raise roslib.packages.InvalidROSPkgException("""
93 Package '%(package_dir)s' is improperly configured: no manifest file is present.
94 """%locals())
95 return p
96 except roslib.packages.InvalidROSPkgException as e:
97 if required:
98 raise
99
101 """
102 @param package str: package name
103 @type package: str
104 @param env: override os.environ dictionary
105 @type env: dict
106 @param required: require that the directory exist
107 @type required: bool
108 @return: path to manifest file of package
109 @rtype: str
110 @raise InvalidROSPkgException: if required is True and manifest file cannot be located
111 """
112
113
114
115 if env is None:
116 env = os.environ
117 d = roslib.packages.get_pkg_dir(package, required, ros_root=env['ROS_ROOT'])
118 return _manifest_file_by_dir(d, required=required, env=env)
119
121 """
122 Load manifest for specified package.
123 @param pacakge: package name
124 @type package: str
125 @return: Manifest instance
126 @rtype: L{Manifest}
127 @raise InvalidROSPkgException: if package is unknown
128 """
129 return parse_file(manifest_file(package))
130
132 """
133 Parse manifest.xml file
134 @param file: manifest.xml file path
135 @type file: str
136 @return: Manifest instance
137 @rtype: L{Manifest}
138 """
139 return roslib.manifestlib.parse_file(Manifest(), file)
140
141 -def parse(string, filename='string'):
142 """
143 Parse manifest.xml string contents
144 @param string: manifest.xml contents
145 @type string: str
146 @return: Manifest instance
147 @rtype: L{Manifest}
148 """
149 v = roslib.manifestlib.parse(Manifest(), string, filename)
150 if v.version:
151 raise ManifestException("<version> tag is not valid in a package manifest.xml file")
152 return v
153