33 from __future__
import with_statement, print_function
38 from rospkg
import MANIFEST_FILE
39 from rospkg.common
import ResourceNotFound
44 for pattern
in patternlist:
47 if re.match(
"^[a-zA-Z0-9_]+$", pattern)
is None:
48 if re.match(pattern, name)
is not None:
57 :param rospack: use rospkg.RosPack()
58 :param rosstack: use rospkg.RosStack()
79 hide_transitives=True,
92 :param hide_transitives:
93 if true, then dependency of children to grandchildren will be hidden if parent has
95 :param show_system: if true, then system dependencies will be shown
98 if selected_names
is None:
103 selected_names = [x
for x
in selected_names
if x
is not None and x !=
'']
104 excludes = [x
for x
in excludes
if x
is not None and x !=
'']
105 if not selected_names:
106 selected_names = [
'.*']
114 "dotcode_factory": dotcode_factory,
115 "with_stacks": with_stacks,
117 "hide_transitives": hide_transitives,
118 "show_system": show_system,
119 "selected_names": selected_names,
120 "excludes": excludes,
121 "ancestors": ancestors,
122 "descendants": descendants,
123 "hide_wet": hide_wet,
128 selection_changed =
False
130 selection_changed =
True
145 if force_refresh
or selection_changed:
153 for name
in self.
rospack.list():
159 for stackname
in self.
rosstack.list():
161 manifest = self.
rosstack.get_manifest(stackname)
162 if manifest.is_catkin:
168 for package_name
in self.
rosstack.packages_of(stackname):
175 'dotcode_factory': dotcode_factory,
179 "simplify": simplify,
180 "colortheme": colortheme,
181 "mark_selected": mark_selected
185 display_changed =
False
187 display_changed =
True
200 if force_refresh
or selection_changed
or display_changed:
207 graph = dotcode_factory.get_graph(rank=self.
rank,
211 packages_in_stacks = []
213 for stackname
in self.
stacks:
222 color = get_color_for_string(stackname)
223 g = dotcode_factory.add_subgraph_to_graph(graph,
231 for package_name
in self.
stacks[stackname][
'packages']:
232 packages_in_stacks.append(package_name)
235 for package_name, attributes
in self.
packages.items():
236 if package_name
not in packages_in_stacks:
238 for name1, name2
in self.
edges.keys():
239 dotcode_factory.add_edge_to_graph(graph, name1, name2)
249 if attributes
and attributes[
'is_catkin']:
253 elif attributes
and not attributes[
'is_catkin']:
255 if attributes
and 'not_found' in attributes
and attributes[
'not_found']:
258 dotcode_factory.add_node_to_graph(graph, package_name, color=color)
261 if stackname
is None or stackname
in self.
stacks:
263 self.
stacks[stackname] = {
'packages': []}
267 adds object based on package_name to self.packages
268 :param parent: packagename which referenced package_name (for debugging only)
276 if catkin_package
is None:
278 self.
packages[package_name] = {
'is_catkin': catkin_package}
282 stackname = self.
rospack.stack_of(package_name)
283 except ResourceNotFound
as e:
285 'RosPackageGraphDotcodeGenerator._add_package(%s), '
286 'parent %s: ResourceNotFound:' % (package_name, parent), e)
288 if not stackname
is None and stackname !=
'':
289 if not stackname
in self.
stacks:
291 self.
stacks[stackname][
'packages'].append(package_name)
298 if self.
hide_wet and catkin_package:
300 if self.
hide_dry and catkin_package
is False:
308 package_path = self.
rospack.get_path(package_name)
309 manifest_file = os.path.join(package_path, MANIFEST_FILE)
310 self.
package_types[package_name] =
not os.path.exists(manifest_file)
311 except ResourceNotFound:
318 self.
edges[(name1, name2)] = attributes
321 self, package_name, expanded_up=None,
322 depth=None, implicit=False, parent=None):
324 :param package_name: the name of package for which to add ancestors
325 :param expanded_up: names that have already been expanded (to avoid cycles)
326 :param depth: how many layers to follow
327 :param implicit: arg to rospack
328 :param parent: package that referenced package_name for error message only
332 if traversed_depth
is None:
334 if depth
is not None and traversed_depth >= depth:
345 if expanded_up
is None:
347 expanded_up.append(package_name)
350 depends_on = self.
rospack.get_depends_on(package_name, implicit=implicit)
351 except ResourceNotFound
as e:
353 'RosPackageGraphDotcodeGenerator.add_package_ancestors_recursively(%s),'
354 ' parent %s: ResourceNotFound:' % (package_name, parent), e)
359 new_nodes.append(dep_on_name)
360 self.
_add_edge(dep_on_name, package_name)
362 expanded_up.append(dep_on_name)
363 for dep_on_name
in new_nodes:
365 expanded_up=expanded_up,
371 self, package_name, expanded=None,
372 depth=None, implicit=False, parent=None):
375 if traversed_depth
is None:
377 if depth
is not None and traversed_depth >= depth:
390 expanded.append(package_name)
394 depends = self.
rospack.get_depends(package_name, implicit=implicit)
395 except ResourceNotFound:
397 manifest = self.
rosstack.get_manifest(package_name)
398 if manifest.is_catkin:
399 depends = [d.name
for d
in manifest.depends]
402 except ResourceNotFound
as e:
404 'RosPackageGraphDotcodeGenerator.add_package_descendants_recursively(%s), '
405 'parent: %s: ResourceNotFound:' % (package_name, parent), e)
409 rosdeps = self.
rospack.get_rosdeps(package_name, implicit=implicit)
414 expanded.append(dep_name)
418 new_nodes.append(dep_name)
421 expanded.append(dep_name)
422 for dep_name
in new_nodes: