Home | Trees | Indices | Help |
|
---|
|
Utility class for assembling code strings into a multiline string. Supports checking for matching parenteses and applying indentation to generate code that is more robust with respect to correctness of program flow and readability of code. Support for the following constructs: {} (basic block), if, else if, else, switch, case, while, do, class Typical usage: >>> c = CodeFormatter() >>> c.begin_switch("i") >>> c.begin_case(0) >>> c += "foo();" >>> c.end_case() >>> c.begin_case(1) >>> c.begin_if("a > b") >>> c += "bar();" >>> c.begin_else_if("c > b") >>> c += "bar2();" >>> c.end_if() >>> c.end_case() >>> c.end_switch() >>> print str(c) switch(i) { case 0: foo(); break; case 1: if( a > b ) { bar(); } else if( c > b ) { bar2(); } break; }
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Mon Jun 11 11:34:21 2012 | http://epydoc.sourceforge.net |