Last active
August 29, 2015 14:14
-
-
Save mhl/06edb1415c6609e1d109 to your computer and use it in GitHub Desktop.
find constituencies with missing SNP candidates
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In [1]: from candidates.static_data import MapItData | |
In [2]: from candidates.popit import create_popit_api_object | |
In [3]: api = create_popit_api_object() | |
In [4]: scottish_cons = [m['id'] for m in MapItData.constituencies_2010.values() if m['country'] == 'S'] | |
In [15]: for post_id in scottish_cons: | |
....: p = api.posts(str(post_id)).get(embed='membership.person')['result'] | |
....: snp_memberships = [memb for memb in p['memberships'] if memb['person_id']['party_memberships'].get('2015', {}).get('id') == 'party:102'] | |
....: if len(snp_memberships) == 0: | |
....: print 'https://yournextmp.com/constituency/{0} seemed to have no SNP candidates'.format(post_id) | |
....: | |
https://yournextmp.com/constituency/14408 seemed to have no SNP candidates | |
https://yournextmp.com/constituency/14440 seemed to have no SNP candidates | |
https://yournextmp.com/constituency/14448 seemed to have no SNP candidates |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment