def main(argv, outstream): """ reads file and prints converted file to stdout """ parser = argparse.ArgumentParser( description='writes converted version of CMakeLists.txt to stdout') parser.add_argument('project_path', nargs='?', default=None, help='The path to the package') parser.add_argument('cmakelists_path', nargs='?', default=None, help='path to the CMakeLists.txt') parser.add_argument('manifest_xml_path', nargs='?', default=None, help='path to the manifest.xml') # Parse args args = parser.parse_args(argv) project_path = args.project_path or os.getcwd() # Convert CMakeLists.txt print(convert_cmake(project_path, args.cmakelists_path, args.manifest_xml_path), file=outstream)
def main(argv, outstream): """ reads file and prints converted file to stdout """ parser = argparse.ArgumentParser(description="writes converted version of CMakeLists.txt to stdout") parser.add_argument("project_path", nargs="?", default=None, help="The path to the package") parser.add_argument("cmakelists_path", nargs="?", default=None, help="path to the CMakeLists.txt") parser.add_argument("manifest_xml_path", nargs="?", default=None, help="path to the manifest.xml") # Parse args args = parser.parse_args(argv) project_path = args.project_path or os.getcwd() # Convert CMakeLists.txt print(convert_cmake(project_path, args.cmakelists_path, args.manifest_xml_path), file=outstream)
def catkinize_package(path, version): """ Calculates a list of changes for one package. changes are 4-tupels of oldfile, backupfile, newfile, contents. This comes before execution so that the user may confirm or reject changes. """ if not os.path.isdir(path): raise ValueError('No directory found at %s' % path) manifest_path = os.path.join(path, 'manifest.xml') if not os.path.isfile(manifest_path): raise ValueError("No rosbuild package at %s, missing manifest.xml" % manifest_path) new_manifest = convert_manifest(path, manifest_path, version) new_cmake = convert_cmake(path) filenames = ['CMakeLists.txt', 'manifest.xml', 'Makefile'] newfiles = ['CMakeLists.txt', 'package.xml', None] contents = [new_cmake, new_manifest, None] return _create_changesets(path, filenames, newfiles, contents)
def catkinize_package(path, version, maintainer_emails): """ Calculates a list of changes for one package. Changes are 4-tupels of oldfile, backupfile, newfile, contents. This comes before execution so that the user may confirm or reject changes. """ if not os.path.isdir(path): raise ValueError('No directory found at %s' % path) manifest_path = os.path.join(path, 'manifest.xml') if not os.path.isfile(manifest_path): raise ValueError( "No rosbuild package at %s, missing manifest.xml" % manifest_path) # add PATH/src/NAME/__init__.py if *.py exists in PATH/src/NAME (because rosbuild did) package_name = os.path.basename(os.path.abspath(path)) print(package_name) if any(filename.endswith('.py') for dirpath, dirnames, filenames in os.walk(os.path.join(path, 'src', package_name)) for filename in filenames): if not os.path.exists(os.path.join(path, 'src', package_name, '__init__.py')): with open(os.path.join(path, 'src', package_name, '__init__.py'), 'wb') as f: pass # build the content of the potential new CMakeLists.txt and packaeg.xml new_manifest = convert_manifest(path, manifest_path, version, maintainer_emails=maintainer_emails) new_cmake = convert_cmake(path) filenames = ['CMakeLists.txt', 'manifest.xml', 'Makefile'] newfiles = ['CMakeLists.txt', 'package.xml', None] contents = [new_cmake, new_manifest, None] if utils.get_python_packages(path): filenames.append('setup.py') newfiles.append('setup.py') contents.append(generate_setup_py(path)) return _create_changesets(path, filenames, newfiles, contents)