ó
    "EñiI  ã            	       ó†   • S SK Jr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	)
é    )ÚIterableÚIterator)ÚIOBase)Úfunctional_datapipe)ÚIterDataPipe)Ú get_file_binaries_from_pathnamesÚFileOpenerIterDataPipeÚ
open_filesc                   ó†   ^ • \ rS rSrSr   SS\\   S\S\S-  S\SS4
U 4S	 jjjrS\	\
\\4      4S
 jrS\4S jrSrU =r$ )r	   é   a%  
Given pathnames, opens files and yield pathname and file stream in a tuple (functional name: ``open_files``).

Args:
    datapipe: Iterable datapipe that provides pathnames
    mode: An optional string that specifies the mode in which
        the file is opened by ``open()``. It defaults to ``r``, other options are
        ``b`` for reading in binary mode and ``t`` for text mode.
    encoding: An optional string that specifies the encoding of the
        underlying file. It defaults to ``None`` to match the default encoding of ``open``.
    length: Nominal length of the datapipe

Note:
    The opened file handles will be closed by Python's GC periodically. Users can choose
    to close them explicitly.

Example:
    >>> # xdoctest: +SKIP
    >>> from torchdata.datapipes.iter import (
    ...     FileLister,
    ...     FileOpener,
    ...     StreamReader,
    ... )
    >>> dp = FileLister(root=".").filter(lambda fname: fname.endswith(".txt"))
    >>> dp = FileOpener(dp)
    >>> dp = StreamReader(dp)
    >>> list(dp)
    [('./abc.txt', 'abc')]
NÚdatapipeÚmodeÚencodingÚlengthÚreturnc                 ó¶   >• [         TU ]  5         Xl        X l        X0l        U R                  S;  a  [        SU 35      eSU;   a  Ub  [        S5      eX@l        g )N)ÚbÚtÚrbÚrtÚrzInvalid mode r   z-binary mode doesn't take an encoding argument)ÚsuperÚ__init__r   r   r   Ú
ValueErrorr   )Úselfr   r   r   r   Ú	__class__s        €Úg/home/mande/repo/quber/.venv/lib/python3.13/site-packages/torch/utils/data/datapipes/iter/fileopener.pyr   ÚFileOpenerIterDataPipe.__init__.   s]   ø€ ô 	‰ÑÔØ'/ŒØŒ	Ø$,Œà�9‰9Ð7Ó7Ü˜}¨T¨FÐ3Ó4Ð4ð �$‹;˜8Ñ/ÜÐLÓMÐMà!�ó    c              #   óv   #   • [        U R                  U R                  U R                  5       S h  v•N   g  N7f)N)r   r   r   r   ©r   s    r   Ú__iter__ÚFileOpenerIterDataPipe.__iter__G   s*   é € Ü3Ø�M‰M˜4Ÿ9™9 d§m¡mó
÷ 	
ó 	
ùs   ‚/9±7²9c                 ó|   • U R                   S:X  a!  [        [        U 5      R                   S35      eU R                   $ )Néÿÿÿÿz# instance doesn't have valid length)r   Ú	TypeErrorÚtypeÚ__name__r!   s    r   Ú__len__ÚFileOpenerIterDataPipe.__len__L   s6   € Ø�;‰;˜"ÓÜœt D›z×2Ñ2Ð3Ð3VÐWÓXÐXØ�{‰{Ðr   )r   r   r   r   )r   Nr%   )r(   Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   ÚstrÚintr   r   Útupler   r"   r)   Ú__static_attributes__Ú__classcell__)r   s   @r   r	   r	      s�   ø† ñðB Ø#Øñ"à˜3‘-ð"ð ð"ð ˜‘*ð	"ð
 ð"ð 
÷"ð "ð2
˜( 5¨¨f¨Ñ#5Ñ6ô 
ð
˜÷ ò r   N)Úcollections.abcr   r   Úior   Ú%torch.utils.data.datapipes._decoratorr   Ú#torch.utils.data.datapipes.datapiper   Ú'torch.utils.data.datapipes.utils.commonr   Ú__all__r1   r/   r	   © r   r   Ú<module>r;      sQ   ðß .Ý å EÝ <Ý Tð ð€ñ
 �\Ó"ô@˜\¨%°°V°Ñ*<Ñ=ó @ó #ñ@r   