#NEWLINE# def splitQuoted( s ) : #NEWLINE# #INDENT# '\n    Like a string split, but don\'t break substrings inside quotes.\n\n    >>> splitQuoted(\'the "hairy monkey" likes pie\')\n    [\'the\', \'hairy monkey\', \'likes\', \'pie\']\n\n    Another one of those "someone must have a better solution for\n    this" things.  This implementation is a VERY DUMB hack done too\n    quickly.\n    ' #NEWLINE# out = [ ] #NEWLINE# quot = None #NEWLINE# phrase = None #NEWLINE# for word in s . split ( ) : #NEWLINE# #INDENT# if ( phrase is None ) : #NEWLINE# #INDENT# if ( word and ( word [ 0 ] in ( '"' , "'" ) ) ) : #NEWLINE# #INDENT# quot = word [ 0 ] #NEWLINE# word = word [ 1 : ] #NEWLINE# phrase = [ ] #NEWLINE# #UNINDENT# #UNINDENT# if ( phrase is None ) : #NEWLINE# #INDENT# out . append ( word ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( word and ( word [ ( - 1 ) ] == quot ) ) : #NEWLINE# #INDENT# word = word [ : ( - 1 ) ] #NEWLINE# phrase . append ( word ) #NEWLINE# out . append ( ' ' . join ( phrase ) ) #NEWLINE# phrase = None #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# phrase . append ( word ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return out