PyNSource Advocacy

I hope that  PyNSource is a significant tool for python users and for the python community - instant UML class diagrams from python source code.

Since the first version, I have had many thousands of downloads - which inspires me to keep working on it.

The trouble with similar python reverse engineering UML tools

The reason I built PyNSource was that I couldn't find a tool that worked.  Here are some observations made several years ago (approx 2008).  Things may have changed since then, so please don't take the following as up to date:

 PyUt is a bit flaky and locks up whilst importing most things (e.g. try reverse engineering PyUt source code using PyUt).  PyUt doesn't recognise associations between classes and you cannot scroll its workspace either!

PyReverse is difficult to install and use, requiring command line complexity plus you need a java tool Argo to view any output - plus it doesn't recognise associations either (last time I looked). Boa is ok (has a UML view) but again, no associations and no ability to combine multiple modules of classes onto the same diagram. 

Update: Enterprise Architect can handle python code, however their parser does not recognise attributes of a class e.g. self.address.  This means only methods get parsed into the resulting UML diagram.  After repeated emails to Sparx System, they refuse to address this issue claiming the parser is built the way it is and cannot be changed.

PyNSource solves all the above problems and even comes as a standalone .exe making it instantly usable.

Displaying UML in Ascii  !!

The PyNSource python code scanner and UML modelling tool can generate UML text diagrams, which you can paste into your source code for documentation purposes.

You can use an Text Art editor to arrange your text UML pictures into properly laid out diagrams and embed them in your doc strings inside your source code.  Here is an example of a UML ascii doc string:

                                                 	       +---------------------------+
             +------------------------------------+            |RoleServicesObject         |
             |AI                                  |            |...........................|
             |.....................................          * |role                       |
             |roleServiceObjects                  '''''''''''''|gameservices               |----- ...|
 +-----+     |gameServices                        |_____       |_rolemanager               |         |
 |game `-.   |....................................|     |      |_etc1                      |         |
 +-----+  `-.|API_RunABit                         |     |      |...........................|         |
             |API_GetOrdersForRole                |     |      |API_GetCurrentStoryline    |         |
             |API_CreateRoleServicesObjectForRole |     |      |API_GetCurrentRoleName     |         |
             +------------------------------------+     |      |API_GetRoleSubordinates    |         |
                                                        |      +---------------------------+         |
                                                        |                                            |
                                                        |                                            |
                                                        | 1 +-------------------------------+ /      |
                                                        .---+GameServices                   |_.......'
                                                            +-------------------------------| -.
                                                            |_scenario                      |
                                                            |_game                          |
                                                            ................................|
                                                            |API_GetAstarTravelTimeBlahBlah |
                                                            |API_GetOobtreeInfoOnOobId      |
                                                            |API_GetOobtreeInfoOnMe         |
                                                            +-------------------------------+
 

You might even be able to use the online ascii drawing tool http://www.asciiflow.com on smaller diagrams (use the import button on this online tool to paste in your pynsource ascii uml).  Then connect your edges/lines using the online tool.

Code Generation

The pynsource command line tool can be set to generate java and delphi skeleton code from python source code, for the purpose of importing (e.g. Java source code) into other UML tools - which might have better layout and other features.  Click here for more information.