
    Th              	           S SK Jr  S SKJr  S SKJr  S SKJr  S SKJ	r	  S/r
\" S5       " S S\	\\\4      5      5       rg	)
    )Iterator)IOBase)Optional)functional_datapipe)IterDataPipeStreamReaderIterDataPiperead_from_streamc                   d    \ rS rSrSr S
S\\\\4      S\	\
   4S jjrS\\\\4      4S jrS	rg)r      a  
Given IO streams and their label names, yield bytes with label name as tuple.

(functional name: ``read_from_stream``).

Args:
    datapipe: Iterable DataPipe provides label/URL and byte stream
    chunk: Number of bytes to be read from stream per iteration.
        If ``None``, all bytes will be read until the EOF.

Example:
    >>> # xdoctest: +SKIP
    >>> from torchdata.datapipes.iter import IterableWrapper, StreamReader
    >>> from io import StringIO
    >>> dp = IterableWrapper([("alphabet", StringIO("abcde"))])
    >>> list(StreamReader(dp, chunk=1))
    [('alphabet', 'a'), ('alphabet', 'b'), ('alphabet', 'c'), ('alphabet', 'd'), ('alphabet', 'e')]
Ndatapipechunkc                     Xl         X l        g N)r   r   )selfr   r   s      f/var/www/fran/franai/venv/lib/python3.13/site-packages/torch/utils/data/datapipes/iter/streamreader.py__init__!StreamReaderIterDataPipe.__init__!   s     !
    returnc              #      #    U R                    H?  u  p UR                  U R                  5      nU(       d  UR                  5         M:  X4v   M;     g 7fr   )r   readr   close)r   furlstreamds       r   __iter__!StreamReaderIterDataPipe.__iter__'   sE      MMLDKK

+LLNi  *s   AA)r   r   r   )__name__
__module____qualname____firstlineno____doc__r   tuplestrr   r   intr   r   bytesr   __static_attributes__ r   r   r   r      sO    ( RV$U3;%78AI# (5e#45  r   N)collections.abcr   ior   typingr   %torch.utils.data.datapipes._decoratorr   #torch.utils.data.datapipes.datapiper   __all__r#   r$   r&   r   r(   r   r   <module>r/      sM    $   E < &
& '(! |E#u*,=> !  )! r   