Coder Social home page Coder Social logo

everypolitician-python's Introduction

EveryPolitician

A Python library for easy access to EveryPolitician data. This is essentially a Python port of everypolitican-ruby.

This has been tested with Python 2.7 and Python 3.5.

Installation

You can install this package from PyPi with:

pip install everypolitician

Usage

Creating a instance of the EveryPolitican class allows you to access information on countries, their legislatures and legislative periods. Each country and legislature has a slug that can be used to reference them via the country and legislature methods:

from everypolitician import EveryPolitician
ep = EveryPolitician()

australia = ep.country('Australia')
senate = australia.legislature('Senate')
senate # => <Legislature: Senate in Australia>

united_kingdom = ep.country('UK')
house_of_commons = united_kingdom.legislature('Commons')

american_samoa = ep.country('American-Samoa')
house_of_representatives = american_samoa.legislature('House')

for country in ep.countries():
    print country.name, 'has', len(country.legislatures()), 'legislatures'

By default this will get the EveryPolitician data and returns the most recent data. This data is found from the index file, called countries.json, which links to specific versions of other data files.

If you want want to point to a different countries.json file, you can override the default URL by specifying the countries_json_url keyword argument when creating the EveryPolitician object, e.g.:

EveryPolitician(countries_json_url='https://cdn.rawgit.com/everypolitician/everypolitician-data/080cb46/countries.json')

The example above is using a specific commit (indicated by the hash 080cb46). If you want to use a local copy of countries.json you can create the object with the countries_json_filename keyword argument instead, e.g.:

EveryPolitician(countries_json_filename='/home/mark/tmp/countries.json')

For more about countries.json, see this description.

Remember that EveryPolitician data is frequently updated — see this information about using EveryPolitician data.

More information on the EveryPolitician site.

Development

After cloning the repo, you can run the tests on Python 2.7 and Python 3.5 by running:

tox

Or you can create a virtualenv and install the package's dependencies with:

pip install -e .

And run the tests on the Python version your virtualenv was based on with:

pytest

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/everypolitician/everypolitician.

License

The gem is available as open source under the terms of the MIT License.

everypolitician-python's People

Contributors

mhl avatar andylolz avatar

Stargazers

Keyth M Citizen  avatar horlar avatar Victor Miti avatar Emil Møller Rasmussen avatar luis avatar Alexander Mann-Wahrenberg avatar Marco Occhialini avatar Lotti avatar AM avatar pixie avatar Öykü Başerdem avatar Daniel Schwabe avatar  avatar Yasin Balcancı avatar Dmitry Pursanov avatar Nabil BELGASMI avatar  avatar Sam Leon avatar lord-of-the-github avatar Rob Gilmore avatar Jason Volpe avatar Bill Eger avatar Adam Smith Barreto Malcher avatar Håvard Lundberg avatar Kurt Bauer avatar salotz avatar Leonardo avatar Douglas Miranda avatar Mauro Bianchi avatar Gilson Filho avatar György Orosz avatar bosco avatar Ricardo Serrão avatar [ɣʷufd̥] avatar Chris Mytton avatar

Watchers

 avatar Tony Bowden avatar M Somerville avatar  avatar Zarino Zappia avatar James Cloos avatar  avatar Myfanwy Nixon avatar Octopus in Vitro avatar Martin Wright avatar Oliver Denman avatar Jen Bramley avatar  avatar Jason Volpe avatar lord-of-the-github avatar

everypolitician-python's Issues

Error when trying to import module

Problem

I get the following error when I try to import everypolitician:

$ python
Python 2.7.12 (default, Jun 29 2016, 14:05:02) 
[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import everypolitician
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/site-packages/everypolitician/__init__.py", line 1, in <module>
    from .lib import *
  File "/usr/local/lib/python2.7/site-packages/everypolitician/lib.py", line 21, in <module>
    @six.python_2_unicode_compatible
AttributeError: 'module' object has no attribute 'python_2_unicode_compatible'

Which appears to be a problem with six.

$ pip freeze | grep six
six==1.8.0

I've got version 1.8.0, it looks like python_2_unicode_compatible was only added in 1.9.0.

Proposed solution

Make the version of six that we depend on more explicit in setup.py.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.