mirror of
https://github.com/kennethreitz/tablib.git
synced 2026-06-05 15:00:19 +00:00
Merge branch 'release/0.6.2'
This commit is contained in:
+7
-1
@@ -1,10 +1,16 @@
|
||||
History
|
||||
=======
|
||||
|
||||
0.6.2 (2010-09-13)
|
||||
------------------
|
||||
* Fixed Dataset.append() error on empty dataset.
|
||||
* Updated Dataset.headers property w/ validation.
|
||||
* Added Testing Fixtures.
|
||||
|
||||
0.6.1 (2010-09-12)
|
||||
------------------
|
||||
|
||||
* Packaging hotfixes
|
||||
* Packaging hotfixes.
|
||||
|
||||
|
||||
0.6.0 (2010-09-11)
|
||||
|
||||
@@ -127,6 +127,7 @@ If you'd like to contribute, simply fork `the repository`_, commit your changes,
|
||||
|
||||
Roadmap
|
||||
-------
|
||||
- Add ability to add/remove full columns
|
||||
- Import datasets from CSV, JSON, YAML
|
||||
- Release CLI Interface
|
||||
- Auto-detect import format
|
||||
|
||||
@@ -18,7 +18,7 @@ if sys.argv[-1] == "publish":
|
||||
|
||||
setup(
|
||||
name='tablib',
|
||||
version='0.6.1',
|
||||
version='0.6.2',
|
||||
description='Format agnostic tabular data library (XLS, JSON, YAML, CSV)',
|
||||
long_description=open('README.rst').read() + '\n\n' +
|
||||
open('HISTORY.rst').read(),
|
||||
|
||||
+18
-3
@@ -18,7 +18,7 @@ import yaml
|
||||
from helpers import *
|
||||
|
||||
|
||||
__all__ = ['Dataset', 'DataBook']
|
||||
# __all__ = ['Dataset', 'DataBook']
|
||||
|
||||
__name__ = 'tablib'
|
||||
__version__ = '0.6.1'
|
||||
@@ -36,6 +36,7 @@ class Dataset(object):
|
||||
self._saved_file = None
|
||||
self._saved_format = None
|
||||
self._data = list(args)
|
||||
self.__headers = None
|
||||
|
||||
try:
|
||||
self.headers = kwargs['headers']
|
||||
@@ -118,9 +119,23 @@ class Dataset(object):
|
||||
"""Returns the width of the Dataset."""
|
||||
try:
|
||||
return len(self._data[0])
|
||||
except KeyError, why:
|
||||
return 0
|
||||
except IndexError, why:
|
||||
try:
|
||||
return len(self.headers)
|
||||
except TypeError, e:
|
||||
return 0
|
||||
|
||||
@property
|
||||
def headers(self):
|
||||
"""Headers property."""
|
||||
return self.__headers
|
||||
|
||||
@headers.setter
|
||||
def headers(self, collection):
|
||||
"""Validating headers setter."""
|
||||
self._validate(collection)
|
||||
self.__headers = collection
|
||||
|
||||
@property
|
||||
def dict(self):
|
||||
"""Returns python dict of Dataset."""
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import unittest
|
||||
|
||||
import tablib
|
||||
|
||||
class TablibTestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def test_empty_append(self):
|
||||
|
||||
data = tablib.Dataset()
|
||||
|
||||
new_row = (1,2,3)
|
||||
data.append(new_row)
|
||||
|
||||
self.assertTrue(data.width == len(new_row))
|
||||
|
||||
|
||||
def test_empty_append_with_headers(self):
|
||||
|
||||
data = tablib.Dataset()
|
||||
|
||||
data.headers = ['first', 'second']
|
||||
new_row = (1,2,3,4)
|
||||
|
||||
self.assertRaises(tablib.InvalidDimensions, data.append, new_row)
|
||||
|
||||
# def test_adding_header with (self):
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user