diff options
| author | Kenneth Reitz <me@kennethreitz.com> | 2010-11-21 21:33:01 -0500 |
|---|---|---|
| committer | Kenneth Reitz <me@kennethreitz.com> | 2010-11-21 21:33:01 -0500 |
| commit | 22c4d185e122da6ea1c71d17af009a6c55217c39 (patch) | |
| tree | 873a879cef9f3c78d9b012d68e55ffb105c508a1 /tablib | |
| parent | e3b3659ea40151eb849e3f53555900b7ba2c7d43 (diff) | |
| download | tablib-22c4d185e122da6ea1c71d17af009a6c55217c39.tar.gz | |
Export HTML for Databooks.
Diffstat (limited to 'tablib')
| -rw-r--r-- | tablib/formats/_html.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tablib/formats/_html.py b/tablib/formats/_html.py index 786d5a3..13dc055 100644 --- a/tablib/formats/_html.py +++ b/tablib/formats/_html.py @@ -8,9 +8,12 @@ from StringIO import StringIO from tablib.packages import markup import tablib +BOOK_ENDINGS = 'h3' + title = 'html' extentions = ('html', ) + def export_set(dataset): """HTML representation of a Dataset.""" @@ -35,3 +38,16 @@ def export_set(dataset): return stream.getvalue() + +def export_book(databook): + """HTML representation of a Databook.""" + + stream = StringIO() + + for i, dset in enumerate(databook._datasets): + title = (dset.title if dset.title else 'Set %s' % (i)) + stream.write('<%s>%s</%s>\n' % (BOOK_ENDINGS, title, BOOK_ENDINGS)) + stream.write(dset.html) + stream.write('\n') + + return stream.getvalue() |
