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.
Design Considerations¶
Tablib was developed with a few PEP 20 idioms in mind.
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Readability counts.
A few other things to keep in mind:
Keep your code DRY.
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 accessible.
git clone git://github.com/jazzband/tablib.git
The project is hosted on GitHub.
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.
master
Current production release (3.7) on PyPi.
Each release is tagged.
When submitting patches, please place your feature/change in its own branch prior to opening a pull request on GitHub.
Adding New Formats¶
Tablib welcomes new format additions! Format suggestions include:
MySQL Dump
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.
From version 1.0, Tablib formats are class-based and can be dynamically registered.
Write your custom format class:
class MyXXXFormatClass: title = 'xxx' @classmethod def export_set(cls, dset): .... # returns string representation of given dataset @classmethod def export_book(cls, dbook): .... # returns string representation of given databook @classmethod def import_set(cls, dset, in_stream): ... # populates given Dataset with given datastream @classmethod def import_book(cls, dbook, in_stream): ... # returns Databook instance @classmethod def detect(cls, stream): ... # returns True if given stream is parsable as xxx
Excluding Support
If the format excludes support for an import/export mechanism (e.g.
csv
excludesDatabook
support), simply don’t define the respective class methods. Appropriate errors will be raised.Register your class:
from tablib.formats import registry registry.register('xxx', MyXXXFormatClass())
3. From then on, you should be able to use your new custom format as if it were
a built-in Tablib format, e.g. using dataset.export('xxx')
will use the
MyXXXFormatClass.export_set
method.
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.
$ tox
Continuous Integration¶
Every pull request is automatically tested and inspected upon receipt with GitHub Actions. If you broke the build, you will receive an email accordingly.
Anyone may view the build status and history at any time.
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 epub, latex, json, &c similarly.
Make sure to check out the API Documentation.