def _set_edge_attributes(self, edge, gc): if len(self._edge_label_decorators()) > 0: gc.setText("\n".join( CollectionTools.flatten( BaseGraphElementDecorator.decorations( self._edge_label_decorators(), edge)))) # TODO zu langes tooltip/edgetooltip führt bei Graphviz dazu, dass fehlerhaftes SVG erzeugt wird if len(self._edge_tooltip_decorators()) > 0: # TODO wie erzeuge ich einen Zeilenumbruch im Tooltip?? gc.setTooltip( Label(", ".join( CollectionTools.flatten( BaseGraphElementDecorator.decorations( self._edge_tooltip_decorators(), edge))))) edge_attrs = edge.get_attr_names() for (in_attr) in edge_attrs: in_value = edge.get_attr(in_attr) if in_attr == EdgeAttributes.COLOR: gc.setLineColor(self.map_swt_color(in_value)) elif in_attr == EdgeAttributes.WEIGHT: gc.setLineWidth(in_value) elif in_attr == EdgeAttributes.STYLE: gc.setLineStyle(EdgeStyles.map(self.StyleMap, in_value)) elif in_attr in [EdgeAttributes.GROUPED_EDGES]: pass else: logging.warning("Unknown edge attributes %s=%s" % (in_attr, in_value))
def _set_node_attributes(self, node, gn): if len(self._node_label_decorators()) > 0: gn.setText( str(node) + " " + " ".join( CollectionTools.flatten( BaseGraphElementDecorator.decorations( self._node_label_decorators(), node)))) else: gn.setText(str(node)) # TODO zu langes tooltip/edgetooltip führt bei Graphviz dazu, dass fehlerhaftes SVG erzeugt wird if len(self._node_tooltip_decorators()) > 0: # TODO wie erzeuge ich einen Zeilenumbruch im Tooltip?? gn.setTooltip( Label(", ".join( CollectionTools.flatten( BaseGraphElementDecorator.decorations( self._node_tooltip_decorators(), node))))) height = None width = None node_attrs = self._graph().node_attr_names(node) for (in_attr) in node_attrs: in_value = self._graph().node_attr(node, in_attr) # TODO Mapping definieren if in_attr == NodeAttributes.SHAPE: pass #attrs[GraphvizConstants.GRAPHVIZ_ATTR_SHAPE] = GraphShapes.map(self.ShapeMap, in_value) #if attrs[GraphvizConstants.GRAPHVIZ_ATTR_SHAPE] == GraphvizConstants.GRAPHVIZ_SHAPE_TAB \ # and NodeAttributes.HEIGHT not in node_attrs: #attrs["width"] = str(4.0 * float(config_graphviz.get_node_scale())) #attrs["height"] = str(4.0 * float(config_graphviz.get_node_scale())) elif in_attr == NodeAttributes.HEIGHT: height = float(in_value) # str(float(in_value) * float(config_graphviz.get_node_scale())) elif in_attr == NodeAttributes.WIDTH: width = float(in_value) # str(float(in_value) * float(config_graphviz.get_node_scale())) elif in_attr == NodeAttributes.LINE_COLOR: gn.setBorderColor(self.map_swt_color(in_value, SWT.COLOR_BLACK)) elif in_attr == NodeAttributes.FILL_COLOR: gn.setBackgroundColor( self.map_swt_color(in_value, SWT.COLOR_WHITE)) elif in_attr == NodeAttributes.LINK: pass #attrs["href"] = in_value elif in_attr in [ NodeAttributes.GROUPED_NODES, NodeAttributes.SKIPPED_FROM_EDGE, NodeAttributes.SKIPPED_TO_EDGE, NodeAttributes.LABEL ]: pass else: self.__logger.warning("Unknown node attributes %s=%s" % (in_attr, in_value)) if width: gn.setSize(width * 40, height * 40)
def _edge_label(self, edge): if len(self._label_decorators()) > 0: return "\\n".join( CollectionTools.flatten( BaseGraphElementDecorator.decorations( self._label_decorators(), edge))) else: return None
def _tooltip(self, graph_element): if len(self._tooltip_decorators()) > 0: # TODO wie erzeuge ich einen Zeilenumbruch im Tooltip?? return ", ".join( CollectionTools.flatten( BaseGraphElementDecorator.decorations( self._tooltip_decorators(), graph_element))) else: return ""
def _node_label(self, node): nodename = str(node) if self._graph().node_attr(node, NodeAttributes.LABEL) != None: label = self._render_node_name(self._graph().node_attr(node, NodeAttributes.LABEL)) else: label = self._render_node_name(nodename) if len(self._label_decorators()) > 0: if len(label): label += "\\n" label += "\\n".join(CollectionTools.flatten(BaseGraphElementDecorator.decorations(self._label_decorators(), node))) return label
def get_rparts(dirname, num, strict=False, pathmodule=os.path): dirname_parts = dirname.rsplit(pathmodule.sep, num + 1) len_dirname = len( list( CollectionTools.flatten( dir_part.split('.') for dir_part in dirname_parts))) # TODO perhaps the "build" should be required? if not strict and dirname_parts[len(dirname_parts) - 1].lower() == "build": del dirname_parts[len(dirname_parts) - 1] if len_dirname > num: return dirname_parts[len_dirname - num:] else: return dirname_parts
def get_header_list(self): ''' Returns a list of all headers that are referenced in any implementation file that is defined in a module specification. ''' all_files = set( CollectionTools.flatten( config_file_include_deps_supply.get_file_include_deps())) result = [ x for x in all_files if config_cpp_file_configuration.is_header_file(x) ] # TODO filter only headers. Where is the list of valid header extensions defined? self.__logger.info( "%i headers referenced in module spec implementation files" % (len(result))) return result
def test_flatten_3(self): flat_iter = CollectionTools.flatten( ((), (), ()) ) self.assertTrue(hasattr(flat_iter, "__iter__")) self.assertEquals([], list(flat_iter))
def test_flatten_1(self): flat_iter = CollectionTools.flatten( (1,2,(3,(4,5))) ) self.assertTrue(hasattr(flat_iter, "__iter__")) self.assertEquals([1, 2, 3, 4, 5], list(flat_iter))
def _edge_decorations(self, edge): return CollectionTools.flatten(d.decorate(edge) for d in self._edge_label_decorators())