MINI MINI MANI MO
[c           @   s   d  Z  y d d l Z Wn e k
 r5 d d l Z n Xd e f d     YZ d d d d  Z d	   Z d d
  Z	 d d  Z
 e j d d
 k r e
 Z n e	 Z d   Z
 d   Z d S(   s   
utility functions to handle differences in pysqlite versions
These are from Wichert Akkerman <wichert@deephackmode.org>'s python-dhm
http://www.wiggy.net/code/python-dhm
iNt
   TokenizeErrorc           B   s   e  Z d  Z RS(   s   Tokenizer error class(   t   __name__t
   __module__t   __doc__(    (    (    s0   /usr/lib/python2.7/site-packages/yum/sqlutils.pyR       s   s    	
s   "s   \c         C   s  |  g  d d f \ } } } } y,x%| rH| d | k rC d } n | d k rl | d | k rl | d } n | d | k r | d k r | | d 7} q;| j |  d } x | d | k r | d } q Wnk | d | k r| d k r | d } n | | d 7} | d } n' | d k r-| d } n | | d 7} | d } q$ WWn t k
 rft d  n X| ryt d  n  | d k r| j |  n  | S(   s  String tokenizer
    This function tokenizes a string while taking quotation and
    escaping into account.
      >>> import dhm.strtools
      >>> dhm.strtools.Tokenize("this is a test")
      ['this', 'is', 'a', 'test']
      >>> dhm.strtools.Tokenize("this "is a" test")
      ['this', 'is a', 'test']
      >>> dhm.strtools.Tokenize("this \"is\" a test")
      ['this', '"is"', 'a', 'test']
      >>> dhm.strtools.Tokenize("this "is a test")
      Traceback (most recent call last):
        File "<stdin>", line 1, in ?
        File "/usr/local/lib/python2.2/site-packages/dhm/strtools.py", line 80, in Tokenize
          raise TokenizeError, "Unexpected end of string in quoted text"
      dhm.strtools.TokenizeError: Unexecpted end of string in quoted text
    @param        str: string to tokenize
    @type         str: string
    @param whitespace: whitespace characters separating tokens
    @type  whitespace: string
    @param     quotes: legal quoting characters
    @type      quotes: string
    @param    escapes: characters which can escape quoting characters
    @type     escapes: string
    @return: list of tokens
    @rtype:  sequence of strings
    i    i   s   Unexpected end of strings'   Unexpected end of string in quoted textN(   t   Nonet   appendt
   IndexErrorR    (   t   strt
   whitespacet   quotest   escapest   buffert   tokenst   curtokent   quote(    (    s0   /usr/lib/python2.7/site-packages/yum/sqlutils.pyt   Tokenize   s<