Giter VIP home page Giter VIP logo

gobble's Introduction

Build Status Coveralls

Gobble

Gobble is the client API for Open-Spending, an international platform to package, share and visualize budget data. Gobble does exactly the same thing as the packager interface, except programatically. It can be used both as python client or a command line interface. It's compatible with python version 3.6. You can install it via pip.

pip install os-gobble

Fiscal Data Packages

A generic Datapackage is a lightweight container for data. A Fiscal Data Package is a special type of data package for government budget and spending data. It's user-oriented and aims to be extremely easy to use, both for those publishing data (e.g. governments) and for those wanting to use the data (such as researchers and journalists).

Technically speaking, a fiscal datapackage consists of a JSON descriptor pointing to data files. The JSON descriptor needs to follow fiscal data specifications. A basic local fiscal data package could look like this:

/basepath/budget.json   
         /data/budget_2014.csv
               budget_2015.csv

Once your fiscal data package is ready, you can start using Gobble.

Command line interface

Asciinema to come...

Python client

Fiscal data package objects

In Gobble, fiscal data is represented by the FiscalDataPackage class. It's a sub-class of the DataPackage class, defined in the datapackage-py library. To create a FiscalDataPackage object, pass the path of your descriptor to the constructor:

user = User()
budget = FiscalDataPackage('path/to/my/package/descriptor.json', user=user)

Note that as of today, Open-Spending only supports data files in CSV format, so FiscalDataPackage will raise a NotImplementedError error if you try and pass it other formats.

Validation

To validate the fiscal datapackage schema and data:

bugdet.validate()

If the datapackage is invalid, a ValidationError will be raised. To get a list of errors instead (more helpful), set the raise_on_error flag to False.

budget.validate(raise_error=False)

Upload

To upload a fiscal data package to Open-Spending:

url = budget.upload()  # the url of your package in the Open-Spending Viewer

By default, uploaded packages are published straight away. You can toggle the publication state like so:

new_state = budget.toggle('private') # returns 'private'

Search

You can search existing fiscal data packages from the Open-Spending platform like so:

results = search('mexico')
results = search('MX', {'author': 'mickey_mouse'})

where results is a list of datapackages (dict). Available search keys are: size, title, author, description, region, country, city.

Resources

License

Gobble is under MIT License.

Contributions

We welcome feedback, issues and pull-requests. Please check out the contribution guidelines.

gobble's People

Contributors

akariv avatar brew avatar cyberbikepunk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

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.