def lookup(self, **kw): values = dict((k, v) for k, v in kw.items() if v != '') results = query.search(values) print results headings = ['<th>%s</th>' % h for h in zip(*self.headings)[0]] rows = [['<td>%s</td>' % f(v) for h, f in self.headings] for v in results] body = ['<tr>%s</tr>' % ''.join(r) for r in [headings] + rows] table_preamble = '<table border=1>' table = [table_preamble, ''.join(body), '</table>'] return ''.join(table)
import sys, json, pprint path = '/home/coventry/bernie/outreach/' if path not in sys.path: sys.path.append(path) from gobernie import query q = {'RESIDENTIAL_ZIP': '45349', 'FIRST_NAME': 'JOHN', 'LAST_NAME': 'LEWIS', } for result in query.search(q): pprint.pprint(result)