
                         r    d Z ddlmZ ddlmZ ddlmZ ddlZg dZdZ G d d	e      Z	 G d
 de      Z
d Zy)z!A utility for tokenizing strings.    )absolute_import)division)unicode_literalsN)Literal	SeparatorTokenize\c                       e Zd Zy)r   N__name__
__module____qualname__     )lib/googlecloudsdk/core/util/tokenizer.pyr   r          r   r   c                       e Zd Zy)r   Nr   r   r   r   r   r   !   r   r   r   c                 d   g }t        j                         }t        j                  |       }	 |j                  d      }|sn|t        k(  rQ|j                  d      }|r|j	                  |       Ct        dj                  |j                         dz
  |             ||v rW|j                  t        |j                                      |j                  t        |             t        j                         }n|j	                  |       |j                  t        |j                                      |S )a  Tokenizes the given string based on a list of separator strings.

  This is similar to splitting the string based on separators, except
  that this function retains the separators. The separators are
  wrapped in Separator objects and everything else is wrapped in
  Literal objects.

  For example, Tokenize('a:b,c:d', [':', ',']) returns [Literal('a'),
  Separator(':'), Literal('b'), Separator(','), Literal('c'),
  Separator(':'), Literal('d')].

  Args:
    string: str, The string to partition.
    separators: [str], A list of strings on which to partition.


  Raises:
    ValueError: If an unterminated escape sequence is at the
      end of the input.

  Returns:
    [tuple], A list of strings which can be of types Literal or
      Separator.
     z)illegal escape sequence at index {0}: {1})ioStringIOread_ESCAPE_CHARwrite
ValueErrorformattellappendr   getvaluer   )string
separatorstokenscurrbufcs         r   r   r   %   s    2 &	$
F#A	
l	
((1+a	


1DKKHHJNF$ % 	%	
jmmGDMMO,-mmIaL![[]d
jjm# 	& 	--()	-r   )__doc__
__future__r   r   r   r   __all__r   strr   r   r   r   r   r   <module>r*      s=     ( &  ' 	
.c  1r   