Reverse engineer python source code into UML - optionally display UML as Ascii art for pasting into your source code.
Version 1.61 (c) Andy Bulka 2004-2012 andy@andypatterns.com http://www.andypatterns.com/index.php/products/pynsource/ License: GPL 3
========================================
Features:
pyNsourceGui.py
Unlike most off the shelf uml python code importers, pyNsource attempts to recognise tricky composition relationships that are typical in python software development. The expression "self.somevar" is correctly recognised as a UML attribute "somevar". pyNsource attempts to guess the cardinality of associations
Use the built in layout algorithm to help you get started in arranging your classes on the workspace. The layout algorithm uses "spring layout" and animates during layout. Overlap removal means your nodes won't overlap (unless you drag them with the SHIFT key held down). A multipass (slower) 'Optimal' Layout is also available which tries to find the best possible layout, within the constraints of not being able to 'bend' lines.
Hit "v" to toggle between normal UML and Ascii UML view. Ascii UML lets you copy and paste ascii uml text into your source code and text based documentation. Optionally use something like the Java Ascii Versatile Editor http://www.jave.de to wire up your ascii uml classes nicely before pasting into your source code or documentation. See an example of ascii UML at the bottom of this readme.
pynsource.py
The main purpose of this tool is to provide a command line tool which can 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.
Whilst it currently uses the older python parser, it does have the feature (which my current ast based one used in pyNsourceGui.py doesn't) of optionally treating modules as classes, creating a "pseudo class" for each module/file. In such a case, module variables and functions are treated as attributes and methods of a 'class'. I hope to add the "treat modules as 'classes'" feature to the new ast based parser as used by pyNsourceGui.py in the future, as I think it allows us to visualise modules, not just classes.
pyYumlGui.py
This was mainly a fun experiment but seems to work ok. The pynsource.py command line tool can also generate Yuml text from python source code (use the -y option).
========================================
Installation
Windows:
Mac:
Linux:
Run from Source:
========================================
Change Log
Version 1.61 (September 2012)
Version 1.60 (August 2012)
Version 1.52
Version 1.51
Version 1.5
Version 1.4c
Version 1.4b
Version 1.4a
Version 1.4
Smarter detection of composition relationships, as long as classname and variable name are the same (ignoring case) then PyNSource will detect e.g.
class Cat: pass
class A: def init(self, cat): self.cats.append(Cat()) # always has worked, composition detected. self.cats.append(cat) # new 1.4 feature, composition detected here too.
Version 1.3a
========================================
Example of Ascii UML:
+---------------------------+
+------------------------------------+ |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 |
+-------------------------------+
See http://www.andypatterns.com/index.php/products/pynsource/asciiart/ for more into
========================================
SVN repository for pynsource is http://code.google.com/p/pynsource/
Report bugs to http://code.google.com/p/pynsource/issues/list
========================================
Q: What does pynsource mean?
A: Since it was built in Australia, which is famous for its meat pies and sauce at football matches, Pie-and-Sauce. Where Py = Python and Source = source code.
========================================
License
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
========================================