Parse and model Popolo data from EveryPolitician
Project description
This is a port of the Ruby gem everypolitician-popolo <https://github.com/everypolitician/everypolitician-popolo> to Python. Even this README is strongly based on that that gem.
Installation
You can install this package with:
pip install everypolitician-popolo
Usage
You can download a Popolo file manually from EveryPolitician.
The following example uses Åland Lagting (which is the legislature of the Åland islands, available as JSON data from the EveryPolitician page for Åland).
First you’ll need to require the library and read in a file from disk.
from popolo_data.importer import Popolo
popolo = Popolo.from_filename('ep-popolo-v1.0.json')
All Popolo classes used by EveryPolitician are implemented:
There are methods defined for each property on a class, e.g. for a Person:
len(popolo.persons) # => 60 person = popolo.persons.first person.id # => u'e3aab23e-a883-4763-be0d-92e5936024e2' person.name # => u'Aaltonen Carina' person.image # => u'http://www.lagtinget.ax/files/aaltonen_carina.jpg' person.wikidata # => u"Q4934081"
You can also find individual records or collections based on their attributes:
popolo.persons.get(name="Aaltonen Carina")
# => <Person: Aaltonen Carina>
popolo.organizations.filter(classification="party")
# => [<Organization: Liberalerna>,
# <Organization: Liberalerna på Åland r.f.>,
# <Organization: Moderat Samling>,
# <Organization: Moderat Samling på Åland r.f.>,
# <Organization: Moderat samling>,
# <Organization: Moderaterna på Åland>,
# <Organization: Obunden Samling>,
# <Organization: Obunden Samling på Åland>,
# <Organization: Ålands Framtid>,
# <Organization: Ålands Socialdemokrater>,
# <Organization: Ålands framtid>,
# <Organization: Ålands socialdemokrater>,
# <Organization: Åländsk Center>,
# <Organization: Åländsk Center r.f.>,
# <Organization: Åländsk Demokrati>,
# <Organization: Åländsk center>]
Development
After checking out the repo, install the dependencies with:
pip install -r requirements.txt
You can then run the tests with:
tox
To release a new version, update the version number in setup.py and add notes to the CHANGES.txt describing the fixes or new features.
Contributing
Bug reports and pull requests are welcome on GitHub at <https://github.com/everypolitician/everypolitician-popolo-python>.
License
The gem is available as open source under the terms of the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Hashes for everypolitician-popolo-0.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | ab703f07b8e117f3346ae4de5f52af9d4f35a676961863116386f5bdfacc0a34 |
|
MD5 | 8074cd6a808943579c426677bc973cd9 |
|
BLAKE2b-256 | 4a5edfc3d2c1d947137ba996b546fb906156109a780d313c0c9cbb7bda7b19f2 |