Refactor and add yEd GraphML output #1
Closed
+1,229
−452
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I like this project very much but I need to be able to edit the graph after generating it in order to improve the layout and remove a couple of errors. I couldn't find software allowing to do that with pyan's Graphviz dot output.The easiest way I could see was to use yEd's variant of GraphML. At some point I may try to implement Dia output but that would require to use Graphviz to do the layout hence adds some complication (it seems Dia has no automatic layout option).
However I didn't want to loose all the efforts that went to dot output. So I first needed to refactor quite a bit. The coloring stuff went to a colors module with its Colorizer class which knows nothing about output format. Then I have a graph module which contains an abstract class Graph which sits between CallGraphVisitor and the writers. And then I have writers module which actually output something. There is a base class Writer which mostly defines in what order various bits (nodes, subgraphs, edges) are written. It has three subclasses: TgfWriter, DotWriter, YedWriter that know about the output format. Here the result of running pyan on this stuff, with yEd doing the layout: pyan.pdf
I've also done some general clean up. Everything is Pep8'ed and logging uses the standard logging module. There is an new option -l logfile to specify a log file instead of stdout (which is still available using -v). There is also -f filename option to specify an output file. And of course --yed is the new output format option.
For me this version of pyan is more usable and I thought I should give it back. If there is interest I may continue cleaning things and add small improvements. For instance currently this project confuses Graphviz because there is a graph module which results in nodes of the dot file being called graph, which is of course a syntax error... I guess one should expect that kind of problem when running a code analyser on itself (the universe didn't blow up though).