<s> """<STR_LIT>""" <EOL> import tablib <EOL> import sys <EOL> from tablib . packages import omnijson as json <EOL> title = '<STR_LIT>' <EOL> extensions = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> def date_handler ( obj ) : <EOL> return obj . isoformat ( ) if hasattr ( obj , '<STR_LIT>' ) else obj <EOL> def export_set ( dataset ) : <EOL> """<STR_LIT>""" <EOL> return json . dumps ( dataset . dict , default = date_handler ) <EOL> def export_book ( databook ) : <EOL> """<STR_LIT>""" <EOL> return json . dumps ( databook . _package ( ) , default = date_handler ) <EOL> def import_set ( dset , in_stream ) : <EOL> """<STR_LIT>""" <EOL> dset . wipe ( ) <EOL> dset . dict = json . loads ( in_stream ) <EOL> def import_book ( dbook , in_stream ) : <EOL> """<STR_LIT>""" <EOL> dbook . wipe ( ) <EOL> for sheet in json . loads ( in_stream ) : <EOL> data = tablib . Dataset ( ) <EOL> data . title = sheet [ '<STR_LIT:title>' ] <EOL> data . dict = sheet [ '<STR_LIT:data>' ] <EOL> dbook . add_sheet ( data ) <EOL> def detect ( stream ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> json . loads ( stream ) <EOL> return True <EOL> except ValueError : <EOL> return False </s>
