Python, DOT and Visualising Legacy Code The Lazy Way

Preview:

Citation preview

Python, DOT andVisualising Legacy CodeThe Lazy Way

(C) John Chandler 2011

Legacy PHP Code!Noooooooooooooo!!!!

Deep Breaths.Visualise the Code.

Laziness Part 1:Use Python to AnalyseDependencies

Write a PHP Parser in Python?

Or use a regular expression...

(include|require)(?:_once)?[ (]["']([^"']+)["']

Laziness Part 2:Use Graphviz to DrawThe Diagram

Graphviz supports DOT.

DOT is a graphing mini-language

digraph foo {

node1 [label=Node 1];node2 [label=Node 2];

node1 -> node2;

}

$ dot -Tpng -O foo.dot

WTF.Looks like somerefactoring to do

Source is available under GPL v3 from:http://www.bitbucket.org/metaljoe/qadpid