MEPcheck is a Python package for easy and automatic retrieval of voting data about MEPs (Members of European Parliament). Many people complain they don't know what the EU is doing and especially what MEPs from their country are doing. Take control of your representatives and easily show others what's happening in Brussels/Strasbourg!
To try MEPcheck you can install via pip:
pip install mepcheck
Or cloning this GitHub repo:
git clone https://github.com/alanmarazzi/mepcheck.git
Then you can install it as a regular package after installing dependencies:
cd mepcheck
pip install -r requirements.txt
pip install .
After installing you can use MEPcheck directly from the command line with
python mepcheckCLI.py # prints available countries
python mepcheckCLI.py -c spain # prints MEPs from inserted country and their ids
python mepcheckCLI.py --mep 123 # see last 50 votes of a MEP
python mepcheckCLI.py --mep 123 --limit 10 # limit to last 10 votes
python mepcheckCLI.py --mep 123 -s # get a summary by time frame
python mepcheckCLI.py --mep 123 -d json # get votes in json format
You can import the mepcheck
module in Python and use it interactively or programmatically:
from mepcheck import EUvotes, get_meps
Now you can start retrieving data for all MEPs from Votewatch, to check all MEPS and their ids use get_meps
: if you don't pass any argument you'll get a list of all available countries, if you pass a country you'll get a table with all the MEPs from that country and their id for data retrieval:
get_meps()
get_meps(country='latvia')
To get data use the EUvotes
class, you can just pass the id of the MEP you're interested in and then you can take a look at the data right away:
votes = EUvotes(123, limit=20)
print(votes)
votes.print_attendance(summary=True)
To use data you can return all retrieved data in various formats: json, list or if you like in a pandas DataFrame:
votes.data_(shape='list', limit=10)
Note that if you want a DataFrame you have to install pandas since it is not a requirement.
You can also increase or decrease the number of votes stored in the EUvotes object after initialization:
votes.change_limit(limit=200)
If you want MEPcheck to work out of the box and use it from everywhere without messing with your PATH, just build it with Docker.
The process after cloning this repo is:
cd mepcheck
docker build -t mepcheck .
Then just put in your .bashrc
file:
# Remember to put `sudo` before the command if you need to
alias mepcheck='docker run --rm mepcheck'
Now either you source ~/.bashrc
or close and reopen your terminal, at this point you can try it with:
mepcheck --mep 123
I'm open to any kind of contribution: ideas, pull requests and bug signaling are welcome.