示例#1
0
 def model_to_ascii(self):
     wx.BeginBusyCursor(cursor=wx.HOURGLASS_CURSOR)
     m = model_to_ascii_builder()
     try:
         wx.SafeYield()
         s = m.main(self.umlwin.umlworkspace.graph)
         self.multiText.SetValue(str(s))
         if str(s).strip() == "":
             self.multiText.SetValue(ASCII_UML_HELP_MSG)
         self.multiText.ShowPosition(0)
     finally:
         wx.EndBusyCursor()
示例#2
0
 def model_to_ascii(self):
     wx.BeginBusyCursor(cursor=wx.HOURGLASS_CURSOR)
     m = model_to_ascii_builder()
     try:
         wx.SafeYield()
         s = m.main(self.umlwin.umlworkspace.graph)
         self.multiText.SetValue(str(s))
         if str(s).strip() == "":
             self.multiText.SetValue(ASCII_UML_HELP_MSG)
         self.multiText.ShowPosition(0)
     finally:
         wx.EndBusyCursor()
示例#3
0
    def test_8_multiple_inhertitance_render(self):
        # F --|> M
        # F --|> S
        g = Graph()
        f = GraphNode('F', 0, 0, 200, 200)
        m = GraphNode('M', 0, 0, 200, 200)
        s = GraphNode('S', 0, 0, 200, 200)
        g.AddEdge(f, m)['uml_edge_type'] = 'generalisation'
        g.AddEdge(f, s)['uml_edge_type'] = 'generalisation'
        nodelist_normal = [node.id for node in g.nodes]
        """
        Custom ordering allows us to bypass the graph 'nodes_sorted_by_generalisation'
        algorithm which might either be crashing or have unwanted ordering results.
        Thus we can experiment with how different experimental orderings will render.
        """
        mycustom_ordering = [(m, 'root'), (s, 'root'), (f, 'root')]

        from ascii_uml.layout_ascii import model_to_ascii_builder

        m = model_to_ascii_builder()
        s = m.main(g, nodes_annotated_and_sorted=mycustom_ordering)

        expected_s = """
+---+
| M |
+---+
                      
                      
                      
+---+       [ S ][ M ]
| S |        .        
+---+       /_\       
             |        
             |        
            +---+     
            | F |     
            +---+     
        """

        def remove_blank_lines(str):
            return os.linesep.join([s for s in str.splitlines() if s.strip()])

        # remove blank lines, since different margins and paddings in ascii uml layout
        # could cause difference
        expected_s = remove_blank_lines(expected_s)
        s = remove_blank_lines(s)

        #print
        #print "*"*88
        #print expected_s
        #print "*"*88
        #print s
        #print "*"*88

        if s.strip() <> expected_s.strip():
            # Write to file
            with open('logs/test_8_out_actual_.txt', 'w') as f:
                f.write(s)
            with open('logs/test_8_out_expected.txt', 'w') as f:
                f.write(expected_s)

            import difflib
            # delta = difflib.ndiff(s.strip(), expected_s.strip()) # this will always emit something, a visual of the original with changes.
            delta = difflib.unified_diff(s.strip(),
                                         expected_s.strip(),
                                         n=0,
                                         fromfile='actual',
                                         tofile='expected')
            diff_s = ''.join(delta)
            print diff_s

        assert s.strip() == expected_s.strip()
示例#4
0
    def test_8_multiple_inhertitance_render(self):
        # F --|> M
        # F --|> S
        g = Graph()
        f = GraphNode('F', 0, 0, 200, 200)
        m = GraphNode('M', 0, 0, 200, 200)
        s = GraphNode('S', 0, 0, 200, 200)
        g.AddEdge(f, m)['uml_edge_type'] = 'generalisation'
        g.AddEdge(f, s)['uml_edge_type'] = 'generalisation'
        nodelist_normal = [node.id for node in g.nodes]

        """
        Custom ordering allows us to bypass the graph 'nodes_sorted_by_generalisation'
        algorithm which might either be crashing or have unwanted ordering results.
        Thus we can experiment with how different experimental orderings will render.
        """
        mycustom_ordering = [(m, 'root'), (s, 'root'), (f, 'root')]

        from ascii_uml.layout_ascii import model_to_ascii_builder

        m = model_to_ascii_builder()
        s = m.main(g, nodes_annotated_and_sorted=mycustom_ordering)

        expected_s = """
+---+
| M |
+---+
                      
                      
                      
+---+       [ S ][ M ]
| S |        .        
+---+       /_\       
             |        
             |        
            +---+     
            | F |     
            +---+     
        """

        def remove_blank_lines(str):
            return os.linesep.join([s for s in str.splitlines() if s.strip()])
            
        # remove blank lines, since different margins and paddings in ascii uml layout
        # could cause difference
        expected_s = remove_blank_lines(expected_s)
        s = remove_blank_lines(s)
        
        #print
        #print "*"*88
        #print expected_s
        #print "*"*88
        #print s
        #print "*"*88
        
        if s.strip() <> expected_s.strip():
            # Write to file
            with open('logs/test_8_out_actual_.txt','w') as f: f.write(s)
            with open('logs/test_8_out_expected.txt','w') as f: f.write(expected_s)

            import difflib
            # delta = difflib.ndiff(s.strip(), expected_s.strip()) # this will always emit something, a visual of the original with changes.
            delta = difflib.unified_diff(s.strip(), expected_s.strip(), n=0,
                                fromfile='actual', tofile='expected')
            diff_s = ''.join(delta)
            print diff_s
        
        assert s.strip() == expected_s.strip()