Time for some testing.

This commit is contained in:
Kenneth Reitz
2010-08-29 23:38:03 -04:00
parent a2f59584e4
commit 2b3f277138
2 changed files with 19 additions and 5 deletions
+13 -4
View File
@@ -9,7 +9,9 @@
import csv
from helpers import *
__all__ = ['Dataset', 'source']
__version__ = '0.0.3'
__build__ = '0x000003'
@@ -17,8 +19,6 @@ __author__ = 'Kenneth Reitz'
__license__ = 'MIT'
__copyright__ = 'Copyright 2010 Kenneth Reitz'
__all__ = ['Dataset', 'source']
class Dataset(object):
@@ -39,7 +39,15 @@ class Dataset(object):
def __getitem__(self, key):
return self._data[key]
if is_string(key):
if key in self.headers:
pos = self.headers.index(key) # get 'key' index from each data
return [row[pos] for row in self._data]
else:
raise KeyError
else:
return self._data[key]
def __setitem__(self, key, value):
@@ -93,7 +101,8 @@ class Dataset(object):
@property
def json(self):
pass
if self.headers:
pass
@property
+6 -1
View File
@@ -15,6 +15,11 @@ class Object(object):
def piped():
"""Returns piped input via stdin, else False"""
with sys.stdin as stdin:
return stdin.read() if not stdin.isatty() else None
def is_string(obj):
"""Tests if an object is a string"""
return True if type(obj).__name__ == 'str' else False