def _split_query(query):
 qq = query.split(' ')
 keywords = []
 accum = None
 for kw in qq:
  if (accum is None):
   if kw.startswith('"'):
    accum = kw[1:]
   elif kw:
    keywords.append(kw)
  else:
   accum += (' ' + kw)
   if kw.endswith('"'):
    keywords.append(accum[0:(-1)])
    accum = None
 if (accum is not None):
  keywords.append(accum)
 return [kw.strip() for kw in keywords if kw.strip()]

def _split_query ( query ) : qq = query . split ( ' ' ) keywords = [ ] accum = None for kw in qq : if ( accum is None ) : if kw . startswith ( '"' ) : accum = kw [ 1 : ] elif kw : keywords . append ( kw ) else : accum += ( ' ' + kw ) if kw . endswith ( '"' ) : keywords . append ( accum [ 0 : ( - 1 ) ] ) accum = None if ( accum is not None ) : keywords . append ( accum ) return [ kw . strip ( ) for kw in keywords if kw . strip ( ) ]
split and strip keywords .