Development

Tablib is under active development, and contributors are welcome.

If you have a feature request, suggestion, or bug report, please open a new issue on GitHub. To submit patches, please send a pull request on GitHub.

If you’d like to contribute, there’s plenty to do. Here’s a short todo list.

  • Add seperator support to HTML out
  • Hooks System - pre/post-append - pre/post-import - pre/post-export
  • Big Data
  • Backwards-compatible OrderedDict support
  • Write more exhausive unit-tests.
  • Write stress tests.
  • Make CSV write customizable.
  • Integrate django-tablib
  • Mention django-tablib in Documention
  • Dataset title usage in documentation (#17)

Design Considerations

Tablib was developed with a few PEP 20 idioms in mind.

  1. Beautiful is better than ugly.
  2. Explicit is better than implicit.
  3. Simple is better than complex.
  4. Complex is better than complicated.
  5. Readability counts.

A few other things to keep in mind:

  1. Keep your code DRY.
  2. Strive to be as simple (to use) as possible.

Source Control

Tablib source is controlled with Git, the lean, mean, distributed source control machine.

The repository is publicly accessable.

git clone git://github.com/kennethreitz/tablib.git

The project is hosted both on GitHub and git.kennethreitz.com.

Git Branch Structure

Feature / Hotfix / Release branches follow a Successful Git Branching Model . Git-flow is a great tool for managing the repository. I highly recommend it.

develop
The “next release” branch. Likely unstable.
master
Current production release (0.9.5) on PyPi.
gh-pages
Current release of http://tablib.org.

Each release is tagged.

When submitting patches, please place your feature/change in its own branch prior to opening a pull reqeust on GitHub.

Adding New Formats

Tablib welcomes new format additions! Format suggestions include:

  • Tab Separated Values
  • MySQL Dump
  • HTML Table

Coding by Convention

Tablib features a micro-framework for adding format support. The easiest way to understand it is to use it. So, let’s define our own format, named xxx.

  1. Write a new format interface.

    tablib.core follows a simple pattern for automatically utilizing your format throughout Tablib. Function names are crucial.

    Example tablib/formats/_xxx.py:

    title = 'xxx'
    
    def export_set(dset):
        ....
        # returns string representation of given dataset
    
    def export_book(dbook):
        ....
        # returns string representation of given databook
    
    def import_set(dset, in_stream):
        ...
        # populates given Dataset with given datastream
    
    def import_book(dbook, in_stream):
        ...
        # returns Databook instance
    
    def detect(stream):
        ...
        # returns True if given stream is parsable as xxx
    

Excluding Support

If the format excludes support for an import/export mechanism (eg. csv excludes Databook support), simply don’t define the respective functions. Appropriate errors will be raised.

  1. Add your new format module to the tablib.formats.avalable tuple.
  2. Add a mock property to the Dataset class with verbose reStructured Text docstring. This alleviates IDE confusion, and allows for pretty auto-generated Sphinx documentation.
  3. Write respective tests.

Testing Tablib

Testing is crucial to Tablib’s stability. This stable project is used in production by many companies and developers, so it is important to be certain that every version released is fully operational. When developing a new feature for Tablib, be sure to write proper tests for it as well.

When developing a feature for Tablib, the easiest way to test your changes for potential issues is to simply run the test suite directly.

$ ./test_tablib.py

Hudson CI, amongst other tools, supports Java’s xUnit testing report format. Nose allows us to generate our own xUnit reports.

Installing nose is simple.

$ pip install nose

Once installed, we can generate our xUnit report with a single command.

$ nosetests test_tablib.py --with-xunit

This will generate a nosetests.xml file, which can then be analyzed.

Continuous Integration

Every commit made to the develop branch is automatically tested and inspected upon receipt with Hudson CI. If you have access to the main repository and broke the build, you will receive an email accordingly.

Anyone may view the build status and history at any time.

If you are trustworthy and plan to contribute to tablib on a regular basis, please contact Kenneth Reitz to get an account on the Hudson Server.

Additional reports will also be included here in the future, including PEP 8 checks and stress reports for extremely large datasets.

Building the Docs

Documentation is written in the powerful, flexible, and standard Python documentation format, reStructured Text. Documentation builds are powered by the powerful Pocoo project, Sphinx. The API Documentation is mostly documented inline throughout the module.

The Docs live in tablib/docs. In order to build them, you will first need to install Sphinx.

$ pip install sphinx

Then, to build an HTML version of the docs, simply run the following from the docs directory:

$ make html

Your docs/_build/html directory will then contain an HTML representation of the documentation, ready for publication on most web servers.

You can also generate the documentation in ebpub, latex, json, &c similarly.

GitHub Pages

To push the documentation up to GitHub Pages, you will first need to run sphinx-to-github against your docs/_build/html directory.

GitHub Pages are powered by an HTML generation system called Jeckyl, which is configured to ignore files and folders that begin with “_” (ie. _static).

Installing sphinx-to-github is simple.

$ pip install sphinx-to-github

Running it against the docs is even simpler.

$ sphinx-to-github _build/html

Move the resulting files to the gh-pages branch of your repository, and push it up to GitHub.


Make sure to check out the API Documentation.

Table Of Contents

Related Topics

This Page