
    F	h7                         d Z ddlZddlmZmZmZ  G d dej                        Zd Z G d dej                        Z
 G d	 d
      Zd Zd Zd Zd Zy)z
Python3.5+ specific utilities
    N)utilscommoncompatc                       e Zd ZdZd Zy)utf8reader_asynczf
    Takes a utf8-encoded string asynchronous reader and asynchronously reads
    bytes out of it
    c                 v   K   | j                   j                  |       d {   }|j                  d      S 7 w)Nzutf-8)
str_readerreadencode)selfndatas      H/var/www/html/backend/venv/lib/python3.12/site-packages/ijson/utils35.pyr
   zutf8reader_async.read   s1     __))!,,{{7## -s   979N)__name__
__module____qualname____doc__r
        r   r   r   	   s    $r   r   c                    K   t        | j                  d       d{         t        k(  r| j                  S t        j                  t        |       j                        S 7 Cw)z@Returns an awaitable read function that reads the requested typer   N)typer
   bytesr   _warn_and_returnr   )fs    r   	_get_readr      sH     !&&)O%vv""#3A#6#;#;<< s   A"A AA"c                   <    e Zd ZdZej
                  j                  Zy)sendable_dequez/Like utils.sendable_list, but for deque objectsN)r   r   r   r   collectionsdequeappendsendr   r   r   r   r      s    9##Dr   r   c                   "    e Zd ZdZd Zd Zd Zy)async_iterablez
    A utility class that implements an async iterator returning values
    dispatched by a coroutine pipeline after *it* has received values coming
    from an async file-like object.
    c                     t               | _        t        j                  | j                  g| | _        d| _        || _        || _        d | _        y )NF)	r   eventsr   chaincorocoro_finishedr   buf_sizer
   )r   r   r)   coro_pipelines       r   __init__zasync_iterable.__init__#   sB    $&KK<m<	" 	r   c                     | S Nr   )r   s    r   	__aiter__zasync_iterable.__aiter__+   s    r   c                 2  K   | j                   s"t        | j                         d {   | _         | j                  r| j                  j	                         S | j
                  rt        	 | j                  | j                         d {   }	 | j                  j                  |       | j                  r| j                  j	                         S 	 g7 7 J# t        $ r6 d| _        | j                  r| j                  j	                         cY S t        w xY ww)NT)r
   r   r   r%   popleftr(   StopAsyncIterationr)   r'   r!   StopIteration)r   r   s     r   	__anext__zasync_iterable.__anext__.   s     yy'//DI;;;;&&(($$4==11D)		t$;;;;..00 	  0 2
 ! )%)";;;;..00((	)sG   %DCA DC	DA C DD6DDDDN)r   r   r   r   r+   r.   r3   r   r   r   r#   r#      s    )r   r#   c                      d fd	}|S )Nc                 F    t        | |gt        j                  |       S r-   )r#   r   _basic_parse_pipeliner   r)   configbackends      r   basic_parse_asyncz2_make_basic_parse_async.<locals>.basic_parse_asyncC   s)    a 
))'6:
 	
r      r   )r9   r:   s   ` r   _make_basic_parse_asyncr=   B   s    
 r   c                      d fd	}|S )Nc                 F    t        | |gt        j                  |       S r-   )r#   r   _parse_pipeliner7   s      r   parse_asyncz&_make_parse_async.<locals>.parse_asyncJ   s)    a 
##GV4
 	
r   r;   r   )r9   rA   s   ` r   _make_parse_asyncrB   I       
 r   c                      d fd	}|S )Nc           	      J    t        | |gt        j                  |||       S r-   )r#   r   _items_pipeliner   prefixmap_typer)   r8   r9   s        r   items_asyncz&_make_items_async.<locals>.items_asyncQ   s-    a 
##GVXvF
 	
r   Nr<   r   )r9   rJ   s   ` r   _make_items_asyncrL   P   rC   r   c                      d fd	}|S )Nc           	      J    t        | |gt        j                  |||       S r-   )r#   r   _kvitems_pipelinerG   s        r   kvitems_asyncz*_make_kvitems_async.<locals>.kvitems_asyncX   s-    a 
%%gvxH
 	
r   rK   r   )r9   rP   s   ` r   _make_kvitems_asyncrQ   W   s    
 r   )r   r   ijsonr   r   r   
utf8readerr   r   r   r   r#   r=   rB   rL   rQ   r   r   r   <module>rT      s]     ' '$v(( $=$[&& $#) #)Lr   