0

I plan to use dia to create an UML diagram, and then dia2code to generate a python code.

The dia examples are useful:

# Operations
def add_update(self):
    """function add_update

    returns 
    """
    But here, i have nothing
    return None # should raise NotImplementedError()

I added "But here, i have nothing" in the generated code but is it possible to to do that automatically ? In my utopian world, I can:

  1. edit my UML diagram

  2. update the code of each method, depending on my constantly changing project, into the dia diagram

  3. use dia2code to generate the final code

I used Umbrello to do that but it often crashes on my Mint, I gave up.

Did I miss something in dia ? Do your have a trick to do that ? Do you know another software ?

Thanks in advance for your time,

Bibi

Bibi Babo
  • 13
  • 6
  • Real UML modeling tools don't focus on pictures and on reverse-engineering pictures. Instead they focus on building of UML model which can be visualized using many different pictures. See http://en.wikipedia.org/wiki/List_of_Unified_Modeling_Language_tools for some list of candidates (including free or open source) – xmojmr Feb 04 '15 at 05:59

1 Answers1

0

Have you tried GenMyModel? You can now create UML models and use the UML2python generator directly from your browser. You could also personalize the generator to your particular needs. blog post about the UML2Python generator

Xaelis
  • 1,609
  • 10
  • 17
  • I have the same problem with GenMyModel but i found a trick ! ;-) But it doesn't work properly :-(. Changing the script simpleUML2python, line 150 and 152, by removing """. Now, when I write in the "Documentation" section of a method, it's generated without """, so it's code. But it works for only one line. For 2 lines, it generates: "print ('bibi')
    print ('babo')"
    – Bibi Babo Feb 05 '15 at 22:04
  • 1
    Actually, the description field is used for documentation. That's why the generator will write """ at the beginning and at the end of the documentation and that this field as kind of "HTML" format. With your mod, you can add this query: `[query public prepCode(s : String) : String = s.replaceAll('
    ', '\n') /]` and modify line 208 `[c._body/]` to `[c._body.prepCode()/]` this should do the work. Perhaps you will also have to modify `bodyOperation` template. Also, using protected block in the code, you can re-generate on your file without loosing the code you wrote in the gen file.
    – Vincent Aranega Feb 06 '15 at 11:03
  • Thanks for your help, I didn't try this for the moment. A colleague talked to me about BOUML and it's present in your link, xmojmr. It should be natively able to generate the body without tricks, see: "Operation dialog, tab Python" in http://www.bouml.fr/doc/operation.html#Menu%20:%20edit%7Coutline. This evening, I'll try this tool and I let know if it works fine. If not, I'll use your modification in GenMyModel. What a pity, online editing in GenMyModel was so interesting ! – Bibi Babo Feb 11 '15 at 18:56