def test_is_catkin(): from rospkg.manifest import MANIFEST_FILE, parse_manifest_file d = get_test_dir() m = parse_manifest_file(os.path.join(d, 'catkin'), MANIFEST_FILE) assert m.is_catkin m = parse_manifest_file(os.path.join(d, 'example1'), MANIFEST_FILE) assert not m.is_catkin
def extract_notification_recipients(docspace, doc_conf): repo_path = os.path.realpath("%s" % (docspace)) _, manifest_packages, catkin_packages, _ = build_repo_structure(repo_path, doc_conf, []) notification_recipients = set([]) email_pattern = re.compile('([a-zA-Z0-9._%\+-]+@[a-zA-Z0-9._%-]+\.[a-zA-Z]{2,6})') for package_name in set(catkin_packages.keys()) | set(manifest_packages.keys()): if package_name in catkin_packages: package_path = catkin_packages[package_name] from catkin_pkg.package import parse_package pkg = parse_package(package_path) for m in pkg.maintainers: notification_recipients.add(m.email) else: package_path = manifest_packages[package_name] from rospkg import MANIFEST_FILE, STACK_FILE from rospkg.manifest import parse_manifest_file if os.path.exists(os.path.join(package_path, MANIFEST_FILE)): pkg = parse_manifest_file(package_path, MANIFEST_FILE) elif os.path.exists(os.path.join(package_path, STACK_FILE)): pkg = parse_manifest_file(package_path, STACK_FILE) else: assert False, "Path '%s' does not neither contain a manifest.xml nor a stack.xml file" % package_path if pkg.author: for email in email_pattern.finditer(pkg.author): notification_recipients.add(email.group(1)) if notification_recipients: print('Notification recipients: %s' % ' '.join(sorted(notification_recipients)))
def test_is_catkin(): from rospkg.manifest import parse_manifest_file, MANIFEST_FILE, STACK_FILE d = get_test_dir() m = parse_manifest_file(os.path.join(d, 'catkin'), MANIFEST_FILE) assert m.is_catkin m = parse_manifest_file(os.path.join(d, 'example1'), MANIFEST_FILE) assert not m.is_catkin
def extract_notification_recipients(docspace, doc_conf): repo_path = os.path.realpath("%s" % (docspace)) _, manifest_packages, catkin_packages, _ = build_repo_structure(repo_path, doc_conf, []) notification_recipients = set([]) email_pattern = re.compile("([a-zA-Z0-9._%\+-]+@[a-zA-Z0-9._%-]+\.[a-zA-Z]{2,6})") for package_name in set(catkin_packages.keys()) | set(manifest_packages.keys()): if package_name in catkin_packages: package_path = catkin_packages[package_name] from catkin_pkg.package import parse_package pkg = parse_package(package_path) for m in pkg.maintainers: notification_recipients.add(m.email) else: package_path = manifest_packages[package_name] from rospkg import MANIFEST_FILE, STACK_FILE from rospkg.manifest import parse_manifest_file if os.path.exists(os.path.join(package_path, MANIFEST_FILE)): pkg = parse_manifest_file(package_path, MANIFEST_FILE) elif os.path.exists(os.path.join(package_path, STACK_FILE)): pkg = parse_manifest_file(package_path, STACK_FILE) else: assert False, "Path '%s' does not neither contain a manifest.xml nor a stack.xml file" % package_path if pkg.author: for email in email_pattern.finditer(pkg.author): notification_recipients.add(email.group(1)) if notification_recipients: print("Notification recipients: %s" % " ".join(sorted(notification_recipients)))
def test_parse_manifest_file(): from rospkg.manifest import parse_manifest_file, MANIFEST_FILE, STACK_FILE d = get_test_dir() m = parse_manifest_file(os.path.join(d, 'example1'), MANIFEST_FILE) _subtest_parse_example1(m) m = parse_manifest_file(os.path.join(d, 'stack_example1'), STACK_FILE) _subtest_parse_stack_example1(m) m = parse_manifest_file(os.path.join(d, 'stack_version'), STACK_FILE) _subtest_parse_stack_version(m)
def _find_plugins(self, export_tag): plugins = [] r = RosPack() for package_name in r.list(): package_path = r.get_path(package_name) manifest_file_path = os.path.join(package_path, MANIFEST_FILE) if os.path.isfile(manifest_file_path): try: manifest = parse_manifest_file(package_path, MANIFEST_FILE) except InvalidManifest as e: qWarning('Could not parse manifest "%s":\n%s' % (manifest_file_path, e)) continue exports = manifest.get_export(export_tag, 'plugin') for export in exports: plugins.append([package_name, str(export)]) continue package_file_path = os.path.join(package_path, PACKAGE_FILE) if os.path.isfile(package_file_path): # only try to import catkin if a PACKAGE_FILE is found try: from catkin_pkg.package import parse_package, InvalidPackage except ImportError as e: qWarning( 'Package "%s" has a package file, but import of parser failed:\n%s' % (package_path, e)) continue try: package = parse_package(package_file_path) except InvalidPackage as e: qWarning('Could not parse package file "%s":\n%s' % (package_file_path, e)) continue for export in package.exports: if export.tagname != export_tag or 'plugin' not in export.attributes: continue plugin_xml_path = export.attributes['plugin'] plugin_xml_path = plugin_xml_path.replace( '${prefix}', package_path) plugins.append([package_name, plugin_xml_path]) continue return plugins
def _find_plugins(self, export_tag, discovery_data): crawl = True if discovery_data: data = discovery_data.get_settings('rqt_gui.RospkgPluginProvider') export_data = data.get_settings(export_tag) crawl = export_tag not in data.child_groups() plugins = [] if crawl: qDebug("RospkgPluginProvider._find_plugins() crawling for plugins of type '%s'" % export_tag) r = RospkgPluginProvider.rospack for package_name in r.list(): package_path = r.get_path(package_name) manifest_file_path = os.path.join(package_path, MANIFEST_FILE) if os.path.isfile(manifest_file_path): try: manifest = parse_manifest_file(package_path, MANIFEST_FILE) except InvalidManifest as e: qWarning('Could not parse manifest "%s":\n%s' % (manifest_file_path, e)) continue exports = manifest.get_export(export_tag, 'plugin') for export in exports: plugins.append([package_name, str(export)]) continue package_file_path = os.path.join(package_path, PACKAGE_FILE) if os.path.isfile(package_file_path): # only try to import catkin if a PACKAGE_FILE is found try: from catkin_pkg.package import parse_package, InvalidPackage except ImportError as e: qWarning('Package "%s" has a package file, but import of parser failed:\n%s' % (package_path, e)) continue try: package = parse_package(package_file_path) except InvalidPackage as e: qWarning('Could not parse package file "%s":\n%s' % (package_file_path, e)) continue for export in package.exports: if export.tagname != export_tag or 'plugin' not in export.attributes: continue plugin_xml_path = export.attributes['plugin'] plugin_xml_path = plugin_xml_path.replace('${prefix}', package_path) plugins.append([package_name, plugin_xml_path]) continue # write crawling information to cache if discovery_data: plugins_by_package = {} for (package_name, export) in plugins: if package_name not in plugins_by_package: plugins_by_package[package_name] = [] plugins_by_package[package_name].append(export) for package_name, exports in plugins_by_package.items(): export_data.set_value(package_name, os.pathsep.join([str(e) for e in exports])) else: # use cached information for package_name in export_data.all_keys(): exports = export_data.value(package_name) if exports: for export in exports.split(os.pathsep): plugins.append([package_name, export]) return plugins
def _find_plugins(self, export_tag, discovery_data): crawl = True if discovery_data: data = discovery_data.get_settings('rqt_gui.RospkgPluginProvider') export_data = data.get_settings(export_tag) crawl = export_tag not in data.child_groups() plugins = [] if crawl: qDebug( "RospkgPluginProvider._find_plugins() crawling for plugins of type '%s'" % export_tag) r = RospkgPluginProvider.rospack for package_name in r.list(): package_path = r.get_path(package_name) manifest_file_path = os.path.join(package_path, MANIFEST_FILE) if os.path.isfile(manifest_file_path): try: manifest = parse_manifest_file(package_path, MANIFEST_FILE) except InvalidManifest as e: qWarning('Could not parse manifest "%s":\n%s' % (manifest_file_path, e)) continue exports = manifest.get_export(export_tag, 'plugin') for export in exports: plugins.append([package_name, str(export)]) continue package_file_path = os.path.join(package_path, PACKAGE_FILE) if os.path.isfile(package_file_path): # only try to import catkin if a PACKAGE_FILE is found try: from catkin_pkg.package import parse_package, InvalidPackage except ImportError as e: qWarning( 'Package "%s" has a package file, but import of parser failed:\n%s' % (package_path, e)) continue try: package = parse_package(package_file_path) except InvalidPackage as e: qWarning('Could not parse package file "%s":\n%s' % (package_file_path, e)) continue for export in package.exports: if export.tagname != export_tag or 'plugin' not in export.attributes: continue plugin_xml_path = export.attributes['plugin'] plugin_xml_path = plugin_xml_path.replace( '${prefix}', package_path) plugins.append([package_name, plugin_xml_path]) continue # write crawling information to cache if discovery_data: plugins_by_package = {} for (package_name, export) in plugins: if package_name not in plugins_by_package: plugins_by_package[package_name] = [] plugins_by_package[package_name].append(export) for package_name, exports in plugins_by_package.items(): export_data.set_value( package_name, os.pathsep.join([str(e) for e in exports])) else: # use cached information for package_name in export_data.all_keys(): exports = export_data.value(package_name) if exports: for export in exports.split(os.pathsep): plugins.append([package_name, export]) return plugins