#NEWLINE# def Deserializer( stream_or_string , **options ) : #NEWLINE# #INDENT# '\n    Deserialize a stream or string of CSV data.\n    ' #NEWLINE# def process_item( item ) : #NEWLINE# #INDENT# m = _LIST_RE . match ( item ) #NEWLINE# if m : #NEWLINE# #INDENT# contents = m . group ( 1 ) #NEWLINE# if ( not contents ) : #NEWLINE# #INDENT# item = [ ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# item = process_m2m ( contents ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( item == 'TRUE' ) : #NEWLINE# #INDENT# item = True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( item == 'FALSE' ) : #NEWLINE# #INDENT# item = False #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( item == 'NULL' ) : #NEWLINE# #INDENT# item = None #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( item in _QUOTED_BOOL_NULL ) or _QUOTED_LIST_RE . match ( item ) ) : #NEWLINE# #INDENT# item = item . strip ( '\'"' ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# return item #NEWLINE# #UNINDENT# def process_m2m( contents ) : #NEWLINE# #INDENT# li = [ ] #NEWLINE# if _NK_LIST_RE . match ( contents ) : #NEWLINE# #INDENT# for item in _NK_SPLIT_RE . split ( contents ) : #NEWLINE# #INDENT# li . append ( process_item ( item ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# li = _SPLIT_RE . split ( contents ) #NEWLINE# #UNINDENT# return li #NEWLINE# #UNINDENT# if isinstance ( stream_or_string , basestring ) : #NEWLINE# #INDENT# stream = StringIO . StringIO ( stream_or_string ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# stream = stream_or_string #NEWLINE# #UNINDENT# reader = UnicodeReader ( stream ) #NEWLINE# header = next ( reader ) #NEWLINE# data = [ ] #NEWLINE# for row in reader : #NEWLINE# #INDENT# if ( row [ : 2 ] == [ 'pk' , 'model' ] ) : #NEWLINE# #INDENT# header = row #NEWLINE# continue #NEWLINE# #UNINDENT# d = dict ( zip ( header [ : 2 ] , row [ : 2 ] ) ) #NEWLINE# d [ 'fields' ] = dict ( zip ( header [ 2 : ] , map ( process_item , row [ 2 : ] ) ) ) #NEWLINE# data . append ( d ) #NEWLINE# #UNINDENT# for obj in PythonDeserializer ( data , ** options ) : #NEWLINE# #INDENT# ( yield stream_or_string )