Auto-detectors operational.

This commit is contained in:
Kenneth Reitz
2010-09-25 18:03:03 -04:00
parent d479c5735a
commit eaa4de7793
6 changed files with 76 additions and 4 deletions
+10
View File
@@ -277,6 +277,16 @@ class Databook(object):
return len(self._datasets)
def detect(stream):
"""Return (format, stream) of given stream."""
for fmt in formats:
try:
if fmt.detect(stream):
return (fmt, stream)
except AttributeError:
pass
return (None, stream)
class InvalidDatasetType(Exception):
"Only Datasets can be added to a DataBook"