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 """ 35 Python path loader for python scripts and applications. Paths are 36 derived from dependency structure declared in ROS manifest files. 37 """ 38 39 import os 40 import sys 41 42 import rospkg 43 44 # bootstrapped keeps track of which packages we've loaded so we don't 45 # update the path multiple times 46 _bootstrapped = [] 47 # _rospack is our cache of ROS package data 48 _rospack = rospkg.RosPack() 4951 vals = rospack.get_depends(package, implicit=True) 52 return [v for v in vals if not rospack.get_manifest(v).is_catkin]5355 """ 56 Update the Python sys.path with package's dependencies 57 58 :param package_name: name of the package that load_manifest() is being called from, ``str`` 59 """ 60 if package_name in _bootstrapped: 61 return 62 sys.path = _generate_python_path(package_name, _rospack) + sys.path6365 """ 66 Added paths for package to paths 67 :param manifest_: package manifest, ``Manifest`` 68 :param pkg_dir: package's filesystem directory path, ``str`` 69 :param paths: list of paths, ``[str]`` 70 """ 71 exports = manifest_.get_export('python','path') 72 if exports: 73 for export in exports: 74 if ':' in export: 75 export = export.split(':') 76 else: 77 export = [export] 78 for e in export: 79 paths.append(e.replace('${prefix}', pkg_dir)) 80 else: 81 dirs = [os.path.join(pkg_dir, d) for d in ['src', 'lib']] 82 paths.extend([d for d in dirs if os.path.isdir(d)])8385 """ 86 Recursive subroutine for building dependency list and python path 87 :raises: :exc:`rospkg.ResourceNotFound` If an error occurs while attempting to load package or dependencies 88 """ 89 if pkg in _bootstrapped: 90 return [] 91 92 # short-circuit if this is a catkin-ized package 93 m = rospack.get_manifest(pkg) 94 if m.is_catkin: 95 _bootstrapped.append(pkg) 96 return [] 97 98 packages = get_depends(pkg, rospack) 99 packages.append(pkg) 100 101 paths = [] 102 try: 103 for p in packages: 104 m = rospack.get_manifest(p) 105 d = rospack.get_path(p) 106 _append_package_paths(m, paths, d) 107 _bootstrapped.append(p) 108 except: 109 if pkg in _bootstrapped: 110 _bootstrapped.remove(pkg) 111 raise 112 return paths113
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Sat Jun 8 20:33:25 2019 | http://epydoc.sourceforge.net |