| Home | Trees | Indices | Help |
|
|---|
|
|
1 #! /usr/bin/env python
2 # Software License Agreement (BSD License)
3 #
4 # Copyright (c) 2008, Willow Garage, Inc.
5 # All rights reserved.
6 #
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
9 # are met:
10 #
11 # * Redistributions of source code must retain the above copyright
12 # notice, this list of conditions and the following disclaimer.
13 # * Redistributions in binary form must reproduce the above
14 # copyright notice, this list of conditions and the following
15 # disclaimer in the documentation and/or other materials provided
16 # with the distribution.
17 # * Neither the name of Willow Garage, Inc. nor the names of its
18 # contributors may be used to endorse or promote products derived
19 # from this software without specific prior written permission.
20 #
21 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 # POSSIBILITY OF SUCH DAMAGE.
33 #
34 # Revision $Id: stack_manifest.py 6490 2009-10-12 21:26:50Z kwc $
35 # $Author: kwc $
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 # re-export symbols so that external code does not have to import manifestlib as well
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, 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
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 #TODO: validate
122 return s
123
| Home | Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Fri Jan 11 10:12:16 2013 | http://epydoc.sourceforge.net |