Ejemplo n.º 1
0
def convert_files_to_idl(extension, conversion_function, argv=sys.argv[1:]):
    parser = argparse.ArgumentParser(
        description='Convert {extension} files to .idl'.format_map(locals()))
    parser.add_argument('interface_files',
                        nargs='+',
                        help='The interface files to convert')
    args = parser.parse_args(argv)

    for interface_file in args.interface_files:
        interface_file = pathlib.Path(interface_file)
        package_dir = interface_file.parent.absolute()
        while (len(package_dir.parents)
               and not package_exists_at(str(package_dir))):
            package_dir = package_dir.parent
        if not package_dir.parents:
            print("Could not find package for '{interface_file}'".format_map(
                locals()),
                  file=sys.stderr)
            continue
        warnings = []
        pkg = parse_package(package_dir, warnings=warnings)

        conversion_function(package_dir, pkg.name,
                            interface_file.absolute().relative_to(package_dir),
                            interface_file.parent)
Ejemplo n.º 2
0
def _get_package(path: str):
    """Get the ROS package for the given path."""
    from catkin_pkg.package import has_ros_schema_reference
    from catkin_pkg.package import InvalidPackage
    from catkin_pkg.package import package_exists_at
    from catkin_pkg.package import parse_package

    if not package_exists_at(path):
        return None

    try:
        pkg = parse_package(path)
    except (AssertionError, InvalidPackage) as e:  # noqa: F841
        if has_ros_schema_reference(path):
            logger.debug(
                "Found ROS schema reference in package manifest in '{path}'".
                format_map(locals()))
            logger.warn(
                "Failed to parse ROS package manifest in '{path}': {e}".
                format_map(locals()))
        else:
            logger.debug('Failed to parse potential ROS package manifest in'
                         "'{path}': {e}".format_map(locals()))
        return None

    pkg.evaluate_conditions(os.environ)
    return pkg
Ejemplo n.º 3
0
Archivo: cli.py Proyecto: ros2/rosidl
def convert_files_to_idl(extension, conversion_function, argv=sys.argv[1:]):
    parser = argparse.ArgumentParser(
        description='Convert {extension} files to .idl'.format_map(locals()))
    parser.add_argument(
        'interface_files', nargs='+',
        help='The interface files to convert')
    args = parser.parse_args(argv)

    for interface_file in args.interface_files:
        interface_file = pathlib.Path(interface_file)
        package_dir = interface_file.parent.absolute()
        while (
            len(package_dir.parents) and
            not package_exists_at(str(package_dir))
        ):
            package_dir = package_dir.parent
        if not package_dir.parents:
            print(
                "Could not find package for '{interface_file}'"
                .format_map(locals()), file=sys.stderr)
            continue
        warnings = []
        pkg = parse_package(package_dir, warnings=warnings)

        conversion_function(
            package_dir, pkg.name,
            interface_file.absolute().relative_to(package_dir),
            interface_file.parent)
Ejemplo n.º 4
0
def main(options):

    parent_path = os.getcwd()
    print("parent path: %s" % parent_path)
    package_name = options.name[0]
    print("package name: %s" % package_name)
    package_path = os.path.join(parent_path, package_name)
    print("package path: %s" % package_path)
    print_color("@!@{green}==>@|@! Creating %s package..." % package_name)
    try:
        package_template = PackageTemplate._create_package_template(
            package_name=package_name,
            description=options.description,
            licenses=options.license or [],
            maintainer_names=options.maintainer,
            author_names=options.author,
            version=options.pkg_version,
            catkin_deps=options.dependencies,
            system_deps=options.sys_deps,
            boost_comps=options.boost_comps)
        create_package_files(target_path=package_path,
                             package_template=package_template,
                             rosdistro=options.rosdistro,
                             newfiles={},
                             meta=options.meta)
        print(
            'Successfully created files in %s. Please adjust the values in package.xml.'
            % package_path)
    except ValueError as vae:
        print_color("@{red}[ERROR] %s" % vae)

    if not package_exists_at(package_path):
        print_color("@{red}[ERROR] The %s package was not created." %
                    package_name)
        return 1
    print_color("[INFO] The %s package was created." % package_name)

    folders = [
        'include',
        'include/%s' % package_name, 'src',
        'src/%s' % package_name, 'action', 'config', 'launch', 'msg', 'mmsg',
        'srv'
    ]
    print_color("@!@{green}==>@|@! Organizing package...")
    for folder_name in folders:
        folder_path = os.path.join(package_path, folder_name)
        if not os.path.exists(folder_path):
            os.makedirs(folder_path)
            print_color("[INFO] The %s folder was created in the %s package." %
                        (folder_name, package_name))

    return 0
Ejemplo n.º 5
0
def _get_package(path: str):
    """Get the ROS package for the given path."""
    from catkin_pkg.package import InvalidPackage
    from catkin_pkg.package import package_exists_at
    from catkin_pkg.package import parse_package

    if not package_exists_at(path):
        return None

    try:
        pkg = parse_package(path)
    except (AssertionError, InvalidPackage):
        return None

    pkg.evaluate_conditions(os.environ)
    return pkg
Ejemplo n.º 6
0
def get_package(path):
    """Get the ROS package for the given path."""
    if not package_exists_at(path):
        raise RuntimeError(
            f"Failed to find a ROS package at given path '{path}'")

    try:
        package = parse_package(path)
    except (AssertionError, InvalidPackage) as e:
        if has_ros_schema_reference(path):
            raise RuntimeError(
                f"Failed to parse ROS package manifest in '{path}': {e}")
        else:
            raise RuntimeError(
                f"Failed to parse potential ROS package manifest in '{path}': {e}"
            )
        return None

    package.evaluate_conditions(os.environ)
    return package
Ejemplo n.º 7
0
def document_package(pkg_dir):
    args_dict = {}
    if not package_exists_at(pkg_dir):
        print("No ROS package found at %s" % pkg_dir, file=sys.stderr)
    package = parse_package(pkg_dir)
    args_dict['package_name'] = package.name
    args_dict['package_version'] = package.version
    args_dict['package_short_version'] = '.'.join(package.version.split('.')[0:2])
    args_dict['package_licenses'] = ', '.join(package.licenses)
    doxygen_inputs = [e.content for e in package.exports if e.tagname == 'doxygen_inputs']
    args_dict['doxygen_inputs'] = doxygen_inputs
    args_dict['found_tag_files'] = aggregate_tag_files([d.name for d in package.build_depends + package.build_export_depends])
    args_dict['inventories'] = aggregate_sphinx_inventories([d.name for d in package.build_depends + package.build_export_depends])
    
    sphinx_subprojects = ' '.join([e.content for e in package.exports if e.tagname == 'sphinx_subprojects'])

    expand_templates('/doc_root', '/doc_root', args_dict)

    subprocess.check_call('mkdir -p /output/generated/doxygen/xml'.split())
    subprocess.check_call(('sphinx-build /doc_root /output %s' % sphinx_subprojects).split())