parameters: (line, delimiters=COMMAND_DELIMITERS, final_delim="&", index=None)
docstring: Split shell command line, returning all components as a list, including separators
docstring_summary: Split shell command line, returning all components as a list, including separators
docstring_tokens: Split shell command line returning all components as a list including separators
function: def shplit(line, delimiters=COMMAND_DELIMITERS, final_delim="&", index=None):
      """Split shell command line, returning all components as a list, including separators
      """
      if not line:
          return []
      comps = shlex_split_str(line)
      indices = []
      buf = line
      offset = 0
      for comp in comps:
          ncomp = len(buf) - len(buf.lstrip())
          if ncomp:
              indices.append(offset+ncomp)
              offset += ncomp
              buf = buf[ncomp:]
          ncomp = len(comp)
          while True:
              try:
                  temcomp = shlex_split_str(buf[:ncomp])[0]
              except Exception:
                  temcomp = None
              if temcomp == comp:
                  break
              ncomp += 1
              if ncomp > len(buf):
                  raise Exception("shplit ERROR ('%s','%s')" % (comp, buf))
          comp = buf[:ncomp]
          buf = buf[ncomp:]
  
          if delimiters:
              tembuf = comp.replace(" ", ".").replace(delimiters[0], " ")
              indices += shplit(tembuf, delimiters=delimiters[1:], index=offset)
          else:
              indices.append(offset+ncomp)
  
          offset += ncomp
  
      if buf:
          indices.append(offset+len(buf))
  
      if index is None:
          jprev = 0
          retval = []
          for j in indices:
              retval.append(line[jprev:j])
              jprev = j
          if final_delim and retval and retval[-1].endswith(final_delim) and retval[-1] != final_delim:
              retval[-1] = retval[-1][:-len(final_delim)]
              retval.append(final_delim)
  
          return retval
      else:
          return [j+index for j in indices]
function_tokens: def shplit ( line , delimiters = COMMAND_DELIMITERS , final_delim = "&" , index = None ) : if not line : return [ ] comps = shlex_split_str ( line ) indices = [ ] buf = line offset = 0 for comp in comps : ncomp = len ( buf ) - len ( buf . lstrip ( ) ) if ncomp : indices . append ( offset + ncomp ) offset += ncomp buf = buf [ ncomp : ] ncomp = len ( comp ) while True : try : temcomp = shlex_split_str ( buf [ : ncomp ] ) [ 0 ] except Exception : temcomp = None if temcomp == comp : break ncomp += 1 if ncomp > len ( buf ) : raise Exception ( "shplit ERROR ('%s','%s')" % ( comp , buf ) ) comp = buf [ : ncomp ] buf = buf [ ncomp : ] if delimiters : tembuf = comp . replace ( " " , "." ) . replace ( delimiters [ 0 ] , " " ) indices += shplit ( tembuf , delimiters = delimiters [ 1 : ] , index = offset ) else : indices . append ( offset + ncomp ) offset += ncomp if buf : indices . append ( offset + len ( buf ) ) if index is None : jprev = 0 retval = [ ] for j in indices : retval . append ( line [ jprev : j ] ) jprev = j if final_delim and retval and retval [ - 1 ] . endswith ( final_delim ) and retval [ - 1 ] != final_delim : retval [ - 1 ] = retval [ - 1 ] [ : - len ( final_delim ) ] retval . append ( final_delim ) return retval else : return [ j + index for j in indices ]