+
    &j#                     z    ^ RI Ht  ! R R4      t ! R R]4      t ! R R]4      t ! R R	]4      t]! 4       ;ttR
# )    wrapsc                      a  ] tR t^t o RtRR ltR tR tR tR t	R t
R	 tR
 tRR ltRR ltR tR tR tR t]RR l4       tRtV tR# )Callbackah  
Base class and interface for callback mechanism

This class can be used directly for monitoring file transfers by
providing ``callback=Callback(hooks=...)`` (see the ``hooks`` argument,
below), or subclassed for more specialised behaviour.

Parameters
----------
size: int (optional)
    Nominal quantity for the value that corresponds to a complete
    transfer, e.g., total number of tiles or total number of
    bytes
value: int (0)
    Starting internal counter value
hooks: dict or None
    A dict of named functions to be called on each update. The signature
    of these must be ``f(size, value, **kwargs)``
Nc                L    Wn         W n        T;'       g    / V n        W@n        R # N)sizevaluehookskw)selfr	   r
   r   kwargss   &&&&,h/Users/jameslopez/projects/CWCArchive/cwc-podcast/.venv/lib/python3.14/site-packages/fsspec/callbacks.py__init__Callback.__init__   s    	
[[b
    c                    V # r    r   s   &r   	__enter__Callback.__enter__   s    r   c                &    V P                  4        R # r   close)r   exc_argss   &*r   __exit__Callback.__exit__"   s    

r   c                    R# )zClose callback.Nr   r   s   &r   r   Callback.close%   s    r   c                R    V P                  WV4       VP                  R\        4      # )a  
Return callback for child transfers

If this callback is operating at a higher level, e.g., put, which may
trigger transfers that can also be monitored. The function returns a callback
that has to be passed to the child method, e.g., put_file,
as `callback=` argument.

The implementation uses `callback.branch` for compatibility.
When implementing callbacks, it is recommended to override this function instead
of `branch` and avoid calling `super().branched(...)`.

Prefer using this function over `branch`.

Parameters
----------
path_1: str
    Child's source path
path_2: str
    Child's destination path
**kwargs:
    Arbitrary keyword arguments

Returns
-------
callback: Callback
    A callback instance to be passed to the child method
callback)branchpopDEFAULT_CALLBACKr   path_1path_2r   s   &&&,r   branchedCallback.branched(   s$    : 	FF+zz*&677r   c                :   a a \        S4      R VV 3R ll4       pV# )z9
Wraps a coroutine, and pass a new child callback to it.
c                $    V ^8  d   QhR\         /# )   path2)str)formats   "r   __annotate__*Callback.branch_coro.<locals>.__annotate__O   s     	H 	HS 	Hr   c                    <"   SP                   ! W3/ VB ;_uu_ 4       pS! W3R V/VB G Rj  xL
 uuRRR4       #  L  + '       g   i     R# ; i5i)r!   N)r(   )path1r-   r   childfnr   s   &&, r   func"Callback.branch_coro.<locals>.funcN   sG     u6v66%GuGGG 76G 766s%   A?=?A?A	
	Ar   )r   r5   r6   s   ff r   branch_coroCallback.branch_coroI   s*    
 
r	H 	H 
	H r   c                2    Wn         V P                  4        R# )z
Set the internal maximum size attribute

Usually called if not initially set at instantiation. Note that this
triggers a ``call()``.

Parameters
----------
size: int
N)r	   call)r   r	   s   &&r   set_sizeCallback.set_sizeU   s     			r   c                2    Wn         V P                  4        R# )zU
Set the internal value state

Triggers ``call()``

Parameters
----------
value: int
Nr
   r;   )r   r
   s   &&r   absolute_updateCallback.absolute_updatec   s     
		r   c                X    V ;P                   V,          un         V P                  4        R# )z[
Delta increment the internal counter

Triggers ``call()``

Parameters
----------
inc: int
Nr?   )r   incs   &&r   relative_updateCallback.relative_updatep   s     	

c
		r   c                   V P                   '       g   R# V P                  P                  4       pVP                  V4       V'       dB   WP                   9  d   R# V P                   V,          ! V P                  V P
                  3/ VB # V P                   P                  4       ;'       g    .  F!  pV! V P                  V P
                  3/ VB  K#  	  R# )z
Execute hook(s) with current state

Each function is passed the internal size and current value

Parameters
----------
hook_name: str or None
    If given, execute on this hook
kwargs: passed on to (all) hook(s)
N)r   r   copyupdater	   r
   values)r   	hook_namer   r   hooks   &&,  r   r;   Callback.call}   s     zzzWW\\^
		&

*::i(DJJE"EEJJ%%'--2-DDJJ-"- .r   c              #  H   "   V F  pV P                  4        Vx  K  	  R# 5i)z
Wrap an iterable to call ``relative_update`` on each iterations

Parameters
----------
iterable: Iterable
    The iterable that is being wrapped
N)rD   )r   iterableitems   && r   wrapCallback.wrap   s"      D  "J s    "c                    R# )a  
Set callbacks for child transfers

If this callback is operating at a higher level, e.g., put, which may
trigger transfers that can also be monitored. The passed kwargs are
to be *mutated* to add ``callback=``, if this class supports branching
to children.

Parameters
----------
path_1: str
    Child's source path
path_2: str
    Child's destination path
kwargs: dict
    arguments passed to child method, e.g., put_file.

Returns
-------

Nr   r%   s   &&&&r   r"   Callback.branch   s    , r   c                    R # r   r   )r   ___s   &*,r   no_opCallback.no_op   s    r   c                    V P                   # )z@
If undefined methods are called on this class, nothing happens
)rW   )r   rO   s   &&r   __getattr__Callback.__getattr__   s     zzr   c                    Vf   \         # V# )zTransform callback=... into Callback instance

For the special value of ``None``, return the global instance of
``NoOpCallback``. This is an alternative to including
``callback=DEFAULT_CALLBACK`` directly in a method signature.
)r$   )clsmaybe_callbacks   &&r   as_callbackCallback.as_callback   s     !##r   )r   r   r	   r
   )Nr   N)   r   )__name__
__module____qualname____firstlineno____doc__r   r   r   r   r(   r8   r<   r@   rD   r;   rP   r"   rW   rZ   classmethodr_   __static_attributes____classdictcell____classdict__s   @r   r   r      se     (8B
..0 	 	r   r   c                   *   a  ] tR t^t o RtR tRtV tR# )NoOpCallbackz6
This implementation of Callback does exactly nothing
c                    R # r   r   r   argsr   s   &*,r   r;   NoOpCallback.call   s    r   r   N)rb   rc   rd   re   rf   r;   rh   ri   rj   s   @r   rm   rm      s      r   rm   c                   F   a a ] tR t^t oRtRV 3R lltR tR tRtVt	V ;t
# )DotPrinterCallbackz
Simple example Callback implementation

Almost identical to Callback with a hook that prints a char; here we
demonstrate how the outer layer may print "#" and the inner layer "."
c                4   < Wn         \        SV `  ! R/ VB  R # )Nr   )chrsuperr   )r   chr_to_printr   	__class__s   &&,r   r   DotPrinterCallback.__init__   s    "6"r   c                "    \        R4      VR&   R# )z;Mutate kwargs to add new instance with different print char.r!   N)rs   r%   s   &&&&r   r"   DotPrinterCallback.branch   s    /4zr   c                4    \        V P                  RR7       R# )zJust outputs a character )endN)printru   )r   r   s   &,r   r;   DotPrinterCallback.call   s    dhhBr   )ru   )#)rb   rc   rd   re   rf   r   r"   r;   rh   ri   __classcell__rx   rk   s   @@r   rs   rs      s     #5   r   rs   c                   L   a a ] tR t^t oRtRV 3R lltR tR tR tRt	Vt
V ;t# )TqdmCallbacka7  
A callback to display a progress bar using tqdm

Parameters
----------
tqdm_kwargs : dict, (optional)
    Any argument accepted by the tqdm constructor.
    See the `tqdm doc <https://tqdm.github.io/docs/tqdm/#__init__>`_.
    Will be forwarded to `tqdm_cls`.
tqdm_cls: (optional)
    subclass of `tqdm.tqdm`. If not passed, it will default to `tqdm.tqdm`.

Examples
--------
>>> import fsspec
>>> from fsspec.callbacks import TqdmCallback
>>> fs = fsspec.filesystem("memory")
>>> path2distant_data = "/your-path"
>>> fs.upload(
        ".",
        path2distant_data,
        recursive=True,
        callback=TqdmCallback(),
    )

You can forward args to tqdm using the ``tqdm_kwargs`` parameter.

>>> fs.upload(
        ".",
        path2distant_data,
        recursive=True,
        callback=TqdmCallback(tqdm_kwargs={"desc": "Your tqdm description"}),
    )

You can also customize the progress bar by passing a subclass of `tqdm`.

.. code-block:: python

    class TqdmFormat(tqdm):
        '''Provides a `total_time` format parameter'''
        @property
        def format_dict(self):
            d = super().format_dict
            total_time = d["elapsed"] * (d["total"] or 0) / max(d["n"], 1)
            d.update(total_time=self.format_interval(total_time) + " in total")
            return d

>>> with TqdmCallback(
        tqdm_kwargs={
            "desc": "desc",
            "bar_format": "{total_time}: {percentage:.0f}%|{bar}{r_bar}",
        },
        tqdm_cls=TqdmFormat,
    ) as callback:
        fs.upload(".", path2distant_data, recursive=True, callback=callback)
c                   <  ^ RI H p TP                  RT4      T n        T;'       g    / T n        RT n         \
        ST `  ! T/ TB  R#   \         d   p\        R4      ThRp?ii ; i)r   )tqdmz0Using TqdmCallback requires tqdm to be installedNtqdm_cls)r   ImportErrorr#   	_tqdm_cls_tqdm_kwargsrv   r   )r   tqdm_kwargsrp   r   r   excerx   s   &&*,  r   r   TqdmCallback.__init__'  sm    	!  J5'--2	$)&)  	B	s   A
 
A&A!!A&c                2   V P                   f.   V P                  ! RRV P                  /V P                  B V n         V P                  V P                   n        V P                   P                  V P                  V P                   P                  ,
          4       R # )Ntotalr   )r   r   r	   r   r   rH   r
   nro   s   &*,r   r;   TqdmCallback.call5  s`    99LTYYL$:K:KLDI))				diikk12r   c                h    V P                   e$   V P                   P                  4        R V n         R # R # r   )r   r   r   s   &r   r   TqdmCallback.close;  s&    99 IIOODI !r   c                "    V P                  4       # r   r   r   s   &r   __del__TqdmCallback.__del__@  s    zz|r   )r   r   r   r   )rb   rc   rd   re   rf   r   r;   r   r   rh   ri   r   r   s   @@r   r   r      s$     7r*3
 r   r   N)	functoolsr   r   rm   rs   r   r$   _DEFAULT_CALLBACKr   r   r   <module>r      sL    H HV8    *T8 Tn (4~ 5 $r   