/usr/local/lib/python3.6/site-packages/fsspec/__pycache__
Edit: /usr/local/lib/python3.6/site-packages/fsspec/__pycache__/callbacks.cpython-36.pyc (5927B)
3
8%EgÛ ã @ s8 G d d„ dƒZ G dd„ de ƒZG dd„ de ƒZeƒ ZdS )c @ sl e Zd ZdZddd„Zdd„ Zdd „ Zddd„Zdd
d„Zdd„ Z dd„ Z
dd„ Zdd„ Ze
ddd„ƒZdS )ÚCallbacka¨
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)``
Né c K s || _ || _|pi | _|| _d S )N)ÚsizeÚvalueÚhooksÚkw)Úselfr r r Úkwargs© r ú:/usr/local/lib/python3.6/site-packages/fsspec/callbacks.pyÚ__init__ s
zCallback.__init__c C s || _ | jƒ dS )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 r r r
Úset_size s zCallback.set_sizec C s || _ | jƒ dS )z…
Set the internal value state
Triggers ``call()``
Parameters
----------
value: int
N)r r )r r r r r
Úabsolute_update* s
zCallback.absolute_updateé c C s | j |7 _ | jƒ dS )z‹
Delta increment the internal cuonter
Triggers ``call()``
Parameters
----------
inc: int
N)r r )r Úincr r r
Úrelative_update7 s
zCallback.relative_updatec K sv | j s
dS | jjƒ }|j|ƒ |rH|| j kr0dS | j | | j| jf|ŽS x(| j jƒ pVg D ]}|| j| jf|Ž qXW dS )a
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 Úhookr r r
r D s
z
Callback.callc c s x|D ]}| j ƒ |V qW dS )zÂ
Wrap an iterable to call ``relative_update`` on each iterations
Parameters
----------
iterable: Iterable
The iterable that is being wrapped
N)r )r ÚiterableÚitemr r r
Úwrap[ s
z
Callback.wrapc C s dS )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 Úpath_1Úpath_2r r r r
Úbranchh s zCallback.branchc O s d S )Nr )r Ú_Ú__r r r
Úno_op€ s zCallback.no_opc C s | j S )zP
If undefined methods are called on this class, nothing happens
)r )r r r r r
Ú__getattr__ƒ s zCallback.__getattr__c C s |dkrt S |S )a Transform 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.
N)Ú_DEFAULT_CALLBACK)ÚclsZmaybe_callbackr r r
Úas_callback‰ s zCallback.as_callback)Nr N)r )N)N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r r
r r r r r r r Úclassmethodr# r r r r
r s
r c @ s e Zd ZdZdd„ ZdS )ÚNoOpCallbackz>
This implementation of Callback does exactly nothing
c O s d S )Nr )r Úargsr r r r
r › s zNoOpCallback.callN)r$ r% r&