author Gregory Szorc <>
Mon, 06 Aug 2012 10:23:25 -0700
changeset 101585 e97779ff22631981d1d593a531de55a7a8655655
permissions -rwxr-xr-x
Bug 769976 - Statement reformatting and equality operators You can now call to_source() on Expansion, StringExpansion, Function (and derived), Statement (and derived), Condition (and derived), and StatementList to obtain make "source code" for that entity. This means you can write out make files by constructing an appropriate set of Statement instances. This also implements __eq__ and __ne__ on all of the above. This is being used in the tests to verify that the reformatting code works properly (produces an equivalent StatementList). khuey gave permission to land without review.

#!/usr/bin/env python

import sys
import pymake.parser

filename = sys.argv[1]
source = None

with open(filename, 'rU') as fh:
    source =

statements = pymake.parser.parsestring(source, filename)
print statements.to_source()