#!/usr/bin/python2

import fileinput
import json

for line in fileinput.input():
    cd = json.loads(line)
    try:
        print cd['number'] \
                + ' - Project: ' + cd['project'] \
                + ' - Branch: ' + cd['branch'] \
                + ' - Owner: ' + cd['owner']['username'] + ' (' + cd['owner']['name'] + ' <' + cd['owner']['email'] + '>)' \
                + '\n\t' \
                + 'url: ' + cd['url'] \
                + '\n\t' \
                + 'topic: ' + cd['topic'] \
                + '\n\t' \
                + 'Status: ' + cd['status'] \
                + ' - Patchset: ' + cd['currentPatchSet']['number'] \
                + '\n\t' \
                + 'Subject: ' + cd['subject']
        if cd['currentPatchSet']['approvals']:
            for approval in cd['currentPatchSet']['approvals']:
                print '\t\t' + approval['by']['email'] \
                        + ' - ' + approval['type'] \
                        + '.' + approval['value']
    except KeyError:
        print 'found ' + str(cd['rowCount']) + ' matching change(s)'

