
                         r    S r SSKJr  SSKJr  SSKJr  SSKr/ SQrSr " S S	\5      r	 " S
 S\5      r
S rg)z!A utility for tokenizing strings.    )absolute_import)division)unicode_literalsN)Literal	SeparatorTokenize\c                       \ rS rSrSrg)r       N__name__
__module____qualname____firstlineno____static_attributes__r       )lib/googlecloudsdk/core/util/tokenizer.pyr   r          r   r   c                       \ rS rSrSrg)r   !   r   Nr   r   r   r   r   r   !   r   r   r   c                    / n[         R                  " 5       n[         R                  " U 5      n UR                  S5      nU(       d  OU[        :X  aW  UR                  S5      nU(       a  UR	                  U5        MO  [        SR                  UR                  5       S-
  U 5      5      eXQ;   aX  UR                  [        UR                  5       5      5        UR                  [        U5      5        [         R                  " 5       nOUR	                  U5        M  UR                  [        UR                  5       5      5        U$ )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$ % 	%	
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   