This commit splits out the actual output generation functionality from
the main function. It also adds parameters for specifying a stdin and
stdout file object. This enables external access to the output
generation within python, which could be useful for integrating
subunit-trace output with your own test runner.
Change-Id: Id9fc13b9b70c5b2cc47b48eee6426e7e312eff7f