Refactor versions report.

This patch tries to reduce the code to use a single 'yield'. The reason is that I am about to add support for querying versions and receiving a dict() with version (by adding return_dict=False as a paramater to the function). Having multiple yields leads to multiple "if return_dict: else: ..." - ugly.

I am not quite happy with None + a lambda in the "component" structure, but IMHO this is cleaner than the previous code. Anyone with suggestions on how to improve this?