+
    QV-jf  ã                   óH   € R t ^ RIt^ RIt^ RIHt ^ RIHt  ! R R]4      tR# )zGit LFS related utilitiesN)ÚAbstractContextManager)ÚBinaryIOc                   óœ   a € ] tR t^t o RtV 3R lR ltR tR tRV 3R lR lltV 3R lR	 lt	]
P                  3V 3R
 lR lltR tRtV tR# )ÚSliceFileObja!  
Utility context manager to read a *slice* of a seekable file-like object as a seekable, file-like object.

This is NOT thread safe

Inspired by stackoverflow.com/a/29838711/593036

Credits to @julien-c

Args:
    fileobj (`BinaryIO`):
        A file-like object to slice. MUST implement `tell()` and `seek()` (and `read()` of course).
        `fileobj` will be reset to its original position when exiting the context manager.
    seek_from (`int`):
        The start of the slice (offset from position 0 in bytes).
    read_limit (`int`):
        The maximum number of bytes to read from the slice.

Attributes:
    previous_position (`int`):
        The previous position

Examples:

Reading 200 bytes with an offset of 128 bytes from a file (ie bytes 128 to 327):
```python
>>> with open("path/to/file", "rb") as file:
...     with SliceFileObj(file, seek_from=128, read_limit=200) as fslice:
...         fslice.read(...)
```

Reading a file in chunks of 512 bytes
```python
>>> import os
>>> chunk_size = 512
>>> file_size = os.getsize("path/to/file")
>>> with open("path/to/file", "rb") as file:
...     for chunk_idx in range(ceil(file_size / chunk_size)):
...         with SliceFileObj(file, seek_from=chunk_idx * chunk_size, read_limit=chunk_size) as fslice:
...             chunk = fslice.read(...)

```
c                ó,   <€ V ^8„  d   QhRS[ RS[RS[/# )é   ÚfileobjÚ	seek_fromÚ
read_limit)r   Úint)ÚformatÚ__classdict__s   "€Úk/Volumes/fast/ai/experiments/ui-tars-smoke/.venv/lib/python3.14/site-packages/huggingface_hub/utils/_lfs.pyÚ__annotate__ÚSliceFileObj.__annotate__C   s"   ø€ ÷ %ñ %¡ð %±Sð %Ácñ %ó    c                ó*   € Wn         W n        W0n        R # ©N)r   r	   r
   )Úselfr   r	   r
   s   &&&&r   Ú__init__ÚSliceFileObj.__init__C   s   € ØŒØ"ŒØ$Žr   c                óV  € V P                   P                  4       V n        V P                   P                  ^ \        P
                  4      p\        V P                  WP                  ,
          4      V n	        V P                   P                  V P                  \        P                  4       V # )é    )r   ÚtellÚ_previous_positionÚseekÚosÚSEEK_ENDÚminr
   r	   Ú_lenÚioÚSEEK_SET)r   Úend_of_streams   & r   Ú	__enter__ÚSliceFileObj.__enter__H   sk   € Ø"&§,¡,×"3Ñ"3Ó"5ˆÔØŸ™×)Ñ)¨!¬R¯[©[Ó9ˆÜ˜Ÿ™¨¿¹Õ)GÓHˆŒ	à�‰×Ñ˜$Ÿ.™.¬"¯+©+Ô6Øˆr   c                ón   € V P                   P                  V P                  \        P                  4       R # r   )r   r   r   r    r!   )r   Úexc_typeÚ	exc_valueÚ	tracebacks   &&&&r   Ú__exit__ÚSliceFileObj.__exit__P   s    € Ø�‰×Ñ˜$×1Ñ1´2·;±;Ö?r   c                ó    <€ V ^8„  d   QhRS[ /# )r   Ún©r   )r   r   s   "€r   r   r   S   s   ø€ ÷ ñ ‘cñ r   c                óÖ   € V P                  4       pW P                  8¼  d   R # V P                  V,
          pV P                  P                  V^ 8  d	   V4      pV# \	        W4      4      pV# )r   )r   r   r   Úreadr   )r   r,   ÚposÚremaining_amountÚdatas   &&   r   r/   ÚSliceFileObj.readS   s^   € Ø�i‰i‹kˆØ—)‘)ÔÙØŸ9™9 s�?ÐØ�|‰|× Ñ °Q¸´UÐ!1ÓYˆØˆô ADÀAÓ@XÓYˆØˆr   c                ó    <€ V ^8„  d   QhRS[ /# )r   Úreturnr-   )r   r   s   "€r   r   r   [   s   ø€ ÷ 4ñ 4‘cñ 4r   c                óX   € V P                   P                  4       V P                  ,
          # r   )r   r   r	   ©r   s   &r   r   ÚSliceFileObj.tell[   s   € Ø�|‰|× Ñ Ó" T§^¡^Õ3Ð3r   c                ó,   <€ V ^8„  d   QhRS[ RS[ RS[ /# )r   ÚoffsetÚwhencer5   r-   )r   r   s   "€r   r   r   ^   s'   ø€ ÷ Bñ B™3ð B©ð B¹cñ Br   c                ó8  € V P                   pW0P                  ,           pV\        P                  \        P                  39   dL   V\        P                  8X  d	   W1,           MWA,           p\        V\        W4      4      p\        P                  pMaV\        P                  8X  d>   V P                  P                  4       p\        W5,
          \        WV,
          4      4      pM\        R V R24      hV P                  P                  W4      V P                   ,
          # )zwhence value z is not supported)r	   r   r   r!   r   Úmaxr   ÚSEEK_CURr   r   Ú
ValueErrorr   )r   r:   r;   ÚstartÚendÚcur_poss   &&&   r   r   ÚSliceFileObj.seek^   sÄ   € Ø—‘ˆØ—i‘iÕˆØ”b—k‘k¤2§;¡;Ð/Ô/Ø'-´·±Ô'<�U–^À#Å,ˆFÜ˜¤ FÓ 0Ó1ˆFÜ—[‘[‰FØ”r—{‘{Ô"Ø—l‘l×'Ñ'Ó)ˆGÜ˜�¬#¨f¸GµmÓ*DÓE‰Fä˜}¨V¨HÐ4EÐFÓGÐGØ�|‰|× Ñ  Ó0°4·>±>ÕAÐAr   c              #  ó6   "  € V P                  RR7      x € R# 5i)é   )r,   Ni  @ )r/   r7   s   &r   Ú__iter__ÚSliceFileObj.__iter__l   s   é € Ø�i‰i˜/ˆiÓ*Ô*ùs   ‚)r   r   r   r
   r	   N)éÿÿÿÿ)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r#   r)   r/   r   r   r!   r   rF   Ú__static_attributes__Ú__classdictcell__)r   s   @r   r   r      sS   ø‡ € ñ*÷X%ð %ò
ò@÷ò ÷4ð 4ð /1¯k©k÷ Bò B÷+ð +r   r   )rM   r    r   Ú
contextlibr   Útypingr   r   © r   r   Ú<module>rS      s%   ðñ  ã 	Û 	Ý -Ý ôW+Ð)ö W+r   