#NEWLINE# def _quoted_split( s , separator = ',' , quotes = '"' ) : #NEWLINE# #INDENT# 'Splits a string considering quotes.\n\n    e.g. _quoted_split(\'a,"b,c",d\') -> [\'a\', \'"b,c"\', \'d\']\n    ' #NEWLINE# splits = [ ] #NEWLINE# partial = [ ] #NEWLINE# in_quote = None #NEWLINE# for c in s : #NEWLINE# #INDENT# if in_quote : #NEWLINE# #INDENT# if ( c == c ) : #NEWLINE# #INDENT# in_quote = None #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( c in quotes ) : #NEWLINE# #INDENT# in_quote = c #NEWLINE# #UNINDENT# #UNINDENT# if ( ( not in_quote ) and ( c in separator ) ) : #NEWLINE# #INDENT# if partial : #NEWLINE# #INDENT# splits . append ( '' . join ( partial ) ) #NEWLINE# #UNINDENT# partial = [ ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# partial . append ( c ) #NEWLINE# #UNINDENT# #UNINDENT# if partial : #NEWLINE# #INDENT# splits . append ( '' . join ( partial ) ) #NEWLINE# #UNINDENT# return splits