roscreate: sphinx/nose/catkin conversion
This commit is contained in:
parent
8493153cb0
commit
be31135002
|
@ -0,0 +1,3 @@
|
|||
install(DIRECTORY templates/
|
||||
DESTINATION share/roscreate
|
||||
)
|
|
@ -43,8 +43,12 @@ def print_warning(msg):
|
|||
"""print warning to screen (bold red)"""
|
||||
print('\033[31m%s\033[0m'%msg, file=sys.stderr)
|
||||
|
||||
# utility to compute logged in user name
|
||||
def author_name():
|
||||
"""
|
||||
Utility to compute logged in user name
|
||||
|
||||
:returns: name of current user, ``str``
|
||||
"""
|
||||
import getpass
|
||||
name = getpass.getuser()
|
||||
try:
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
# Software License Agreement (BSD License)
|
||||
#
|
||||
# Copyright (c) 2008, Willow Garage, Inc.
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
# Software License Agreement (BSD License)
|
||||
#
|
||||
# Copyright (c) 2009, Willow Garage, Inc.
|
||||
|
@ -55,8 +54,7 @@ from rospkg import on_ros_path
|
|||
|
||||
def get_templates():
|
||||
"""
|
||||
@return: mapping of file names to templates to instantiate
|
||||
@rtype: {str: str}
|
||||
:returns: mapping of file names to templates to instantiate, ``{str: str}``
|
||||
"""
|
||||
templates = {}
|
||||
templates['stack.xml'] = read_template('stack.tmpl')
|
||||
|
@ -66,8 +64,7 @@ def get_templates():
|
|||
|
||||
def instantiate_template(template, stack, brief, description, author, depends, licenses, review):
|
||||
"""
|
||||
@return: template instantiated with properties
|
||||
@rtype: str
|
||||
:returns: template instantiated with properties, ``str``
|
||||
"""
|
||||
return template%locals()
|
||||
|
||||
|
@ -83,18 +80,12 @@ def _update_depends(depends):
|
|||
|
||||
def create_stack(stack, stack_dir, stack_manifest, author, depends, licenses, show_deps):
|
||||
"""
|
||||
@param stack: name of stack
|
||||
@type stack: str
|
||||
@param stack_dir: path to stack
|
||||
@type stack_dir: str
|
||||
@param stack_manifest: existing stack manifest or None
|
||||
@type stack_manifest: L{roslib.stack_manifest.StackManifest}
|
||||
@param author: name of stack maintainer. Overrides stack_manifest.
|
||||
@type author: str
|
||||
@param depends: map of stack name to packages that use that stack. Overrides stack_manifest.
|
||||
@type depends: {str: [str]}
|
||||
@param licenses: list of licenses present in stack
|
||||
@type licenses: set(str)
|
||||
:param stack: name of stack, ``str``
|
||||
:param stack_dir: path to stack, ``str``
|
||||
:param stack_manifest: existing stack manifest or ``None``, ``StackManifest``
|
||||
:param author: name of stack maintainer. Overrides stack_manifest, ``str``
|
||||
:param depends: map of stack name to packages that use that stack. Overrides stack_manifest, ``{str: [str]}``
|
||||
:param licenses: list of licenses present in stack, ``set(str)``
|
||||
"""
|
||||
|
||||
if show_deps:
|
||||
|
@ -134,9 +125,8 @@ def create_stack(stack, stack_dir, stack_manifest, author, depends, licenses, sh
|
|||
|
||||
def compute_stack_depends_and_licenses(stack_dir):
|
||||
"""
|
||||
@return: depends, licenses
|
||||
@rtype: {str: [str]}, [str]
|
||||
@raise: rospkg.ResourceNotFound
|
||||
:returns: depends, licenses, ``{str: [str]}, [str]``
|
||||
:raises: :exc:`rospkg.ResourceNotFound`
|
||||
"""
|
||||
stack = os.path.basename(os.path.abspath(stack_dir))
|
||||
if os.path.exists(stack_dir):
|
||||
|
@ -197,7 +187,7 @@ def roscreatestack_main():
|
|||
stack = os.path.basename(os.path.abspath(stack_dir))
|
||||
|
||||
if not on_ros_path(stack_dir):
|
||||
print("ERROR: roscreate-stack only work in directories in ROS_PACKAGE_PATH\nPlease update your ROS_PACKAGE_PATH environment variable.", file=sys.stderr)
|
||||
print("ERROR: roscreate-stack only work in directories on your ROS_PACKAGE_PATH\nPlease update your ROS_PACKAGE_PATH environment variable.", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
try:
|
||||
|
@ -227,6 +217,3 @@ def roscreatestack_main():
|
|||
pass
|
||||
|
||||
create_stack(stack, stack_dir, stack_manifest, author, depends, licenses, options.show_deps)
|
||||
|
||||
if __name__ == "__main__":
|
||||
roscreatestack_main()
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
[nosetests]
|
||||
with-coverage=1
|
||||
cover-package=roscreate
|
||||
with-xunit=1
|
|
@ -0,0 +1,50 @@
|
|||
# Software License Agreement (BSD License)
|
||||
#
|
||||
# Copyright (c) 2012, Willow Garage, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials provided
|
||||
# with the distribution.
|
||||
# * Neither the name of Willow Garage, Inc. nor the names of its
|
||||
# contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
def test_author_name():
|
||||
from roscreate.core import author_name
|
||||
assert author_name()
|
||||
|
||||
def test_read_template():
|
||||
from roscreate.core import read_template
|
||||
s = set()
|
||||
# this unit test will break if any of the templates get removed/renamed
|
||||
tests = ['Makefile.tmpl', 'stack.tmpl', 'mainpage.tmpl', 'CMakeLists.stack.tmpl']
|
||||
for f in tests:
|
||||
text = read_template(f)
|
||||
s.add(text)
|
||||
# simple assert to make sure we didn't read the same thing from each template
|
||||
assert len(s) == len(tests)
|
||||
|
||||
# hardcode test against a known template
|
||||
text = read_template('Makefile.tmpl')
|
||||
assert text == 'include $(shell rospack find mk)/cmake.mk'
|
Loading…
Reference in New Issue