Ë
    úš¾jÂ  ã                   ó–   — d Z ddlmZ ddlZddlZddlZddlZddlZddlZddl	m
Z
 d„ Zd„ Zd„ Zdd	„Z G d
„ de«      Z G d„ de«      Zy)zE
Helpers for logging.

This module needs much love to become useful.
é    )Úprint_functionNé   )Úmkdirpc                 ób   — t         j                  j                  d«      rt        d| dz
  «      S | S )z¢Remove .1s to the time under Windows: this is the time it take to
    stat files. This is needed to make results similar to timings under
    Unix, for tests
    Úwinr   gš™™™™™¹?)ÚsysÚplatformÚ
startswithÚmax©Úts    úW/home/spazio/kingdom_calls/work5/transenv/lib/python3.12/site-packages/joblib/logger.pyÚ_squeeze_timer      s+   € ô
 ‡|�|×Ñ˜uÔ%Ü�1�a˜#‘g‹Ðàˆó    c                 ó,   — t        | «      } d| | dz  fz  S )a/  Format a duration in seconds as a human-readable string.

    Returns both seconds and minutes, e.g. ``'12.3s, 0.2min'``.

    Parameters
    ----------
    t : float
        Duration in seconds.

    Returns
    -------
    str
        Formatted string showing the duration in seconds and minutes.
    z%.1fs, %.1fminç      N@©r   r   s    r   Úformat_timer   "   s!   € ô 	�aÓ€AØ˜q ! d¡(˜mÑ+Ð+r   c                 ó<   — t        | «      } | dkD  rd| dz  z  S d| z  S )a]  Format a duration in seconds as a compact human-readable string.

    Returns minutes for durations over 60 seconds, otherwise seconds.

    Parameters
    ----------
    t : float
        Duration in seconds.

    Returns
    -------
    str
        Formatted string: ``'  42.0s'`` for short durations or
        ``' 1.2min'`` for longer ones.
    é<   z%4.1fminr   z %5.1fsr   r   s    r   Úshort_format_timer   5   s.   € ô  	�aÓ€AØˆ2‚vØ˜Q ™XÑ&Ð&à˜A‰Ðr   c                 óØ   — dt         j                  v r)ddl}|j                  «       }|j	                  ddd¬«       nd}t        j                  | ||¬«      }|r j                  d	i |¤Ž |S )
a7  Return a pretty-printed string representation of an object.

    Uses :func:`pprint.pformat` with numpy print options temporarily
    reduced to keep output concise when numpy is available.

    Parameters
    ----------
    obj : object
        The object to format.
    indent : int, optional
        Indentation level passed to :func:`pprint.pformat`. Default is 0.
    depth : int, optional
        Maximum nesting depth passed to :func:`pprint.pformat`. Default is 3.

    Returns
    -------
    str
        Pretty-printed string representation of ``obj``.
    Únumpyr   Né   é@   r   )Ú	precisionÚ	thresholdÚ	edgeitems)ÚdepthÚindent© )r   Úmodulesr   Úget_printoptionsÚset_printoptionsÚpprintÚpformat)Úobjr    r   ÚnpÚprint_optionsÚouts         r   r&   r&   L   sh   € ð( ”#—+‘+ÑÛà×+Ñ+Ó-ˆØ
×Ñ a°2ÀÐÕCàˆÜ
�.‰.˜ E°&Ô
9€CÙØˆ×ÑÑ,˜mÒ,Ø€Jr   c                   ó2   — e Zd ZdZdd„Zd„ Zd„ Zd„ Zd	d„Zy)
ÚLoggerz Base class for logging messages.Nc                 ó4   — || _         |r|| _        yd| _        y)zÔ
        Parameters
        ----------
        depth: int, optional
            The depth of objects printed.
        name: str, optional
            The namespace to log to. If None, defaults to joblib.
        ÚjoblibN)r   Ú_name)Úselfr   Únames      r   Ú__init__zLogger.__init__s   s   € ð ˆŒ
Ù!�Tˆ�
 xˆ�
r   c                 ól   — t        j                  | j                  «      j                  d| ›d|›�«       y ©Nú[z]: )ÚloggingÚ	getLoggerr/   Úwarning©r0   Úmsgs     r   ÚwarnzLogger.warn   s$   € Ü×Ñ˜$Ÿ*™*Ó%×-Ò-ºDÁ#Ð.FÕGr   c                 ó:   — t        j                  d| ›d|›�«       y r4   )r6   Úinfor9   s     r   r=   zLogger.info‚   s   € Ü�Š¢4©Ð-Õ.r   c                 ól   — t        j                  | j                  «      j                  d| ›d|›�«       y r4   )r6   r7   r/   Údebugr9   s     r   r?   zLogger.debug…   s$   € ä×Ñ˜$Ÿ*™*Ó%×+Ò+º$ÁÐ,DÕEr   c                 ó2   — t        ||| j                  ¬«      S )z2Return the formatted representation of the object.)r    r   )r&   r   )r0   r'   r    s      r   ÚformatzLogger.format‰   s   € ä�s 6°·±Ô<Ð<r   )é   N)r   )	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r2   r;   r=   r?   rA   r!   r   r   r,   r,   p   s    „ Ù*ó
0òHò/òFô=r   r,   c                   ó    — e Zd ZdZdd„Zdd„Zy)Ú	PrintTimez3Print and log messages while keeping track of time.Nc                 óð  — |�|�t        d«      ‚t        j                  «       | _        | j                  | _        |� t        j
                  j                  |d«      }|| _        |�ñt        t        j
                  j                  |«      «       t        j
                  j                  |«      rQt        dd«      D ](  }	 t        j                  |d|z  z   |d|dz   z  z   «       Œ* 	 t        j                  ||dz   «       	 t        |d«      5 }|j!                  d«       |j!                  d	t        j"                  | j                  «      z  «       d d d «       y y #  Y Œ£xY w#  Y ŒexY w# 1 sw Y   y xY w#  Y y xY w)
Nz&Cannot specify both logfile and logdirz
joblib.logr   é	   z.%iz.1Úwz
Logging joblib python script
z

---%s---
)Ú
ValueErrorÚtimeÚ	last_timeÚ
start_timeÚosÚpathÚjoinÚlogfiler   ÚdirnameÚexistsÚrangeÚshutilÚmoveÚcopyÚopenÚwriteÚctime)r0   rS   ÚlogdirÚis       r   r2   zPrintTime.__init__”   sQ  € ØÐ 6Ð#5ÜÐEÓFÐFäŸ™›ˆŒØŸ.™.ˆŒØÐÜ—g‘g—l‘l 6¨<Ó8ˆGØˆŒØÐÜ”2—7‘7—?‘? 7Ó+Ô,Ü�w‰w�~‰~˜gÔ&ä˜q !›ò 1�Að1ÜŸ™ G¨e°a©iÑ$7¸À5ÈAÐPQÉEÁ?Ñ9RÕSð1ð-Ü—K‘K ¨°4©Ô8ðÜ˜' 3Ó'ð O¨7Ø—M‘MÐ"DÔEØ—M‘M .´4·:±:¸d¿n¹nÓ3MÑ"MÔN÷Oð Oð! øð1Ù0ûð
-Ù,ú÷Oð OûðñúsC   Â<%EÃ$E Ã>E1 Ä
AE%ÅE1 ÅEÅE"Å%E.Å*E1 Å.E1 Å1E5c                 óÄ  — |s2t        j                   «       | j                  z
  }|›dt        |«      ›�}n,t        j                   «       | j                  z
  }d|||dz  fz  }t	        |t
        j                  ¬«       | j                  �-	 t        | j                  d«      5 }t	        ||¬«       ddd«       t        j                   «       | _        y# 1 sw Y   Œ#xY w#  Y Œ*xY w)zmPrint the time elapsed between the last call and the current
        call, with an optional message.
        z: z%s: %.2fs, %.1f minr   )ÚfileNÚa)	rM   rN   r   rO   Úprintr   ÚstderrrS   rZ   )r0   r:   ÚtotalÚ
time_lapseÚfull_msgÚfs         r   Ú__call__zPrintTime.__call__¸   s»   € ñ ÜŸ™› t§~¡~Ñ5ˆJÚ#&¬°JÔ(?Ð@‰Hô Ÿ™› t§¡Ñ6ˆJØ,°°ZÀÈbÁÐ/QÑQˆHÜˆhœSŸZ™ZÕ(Ø�<‰<Ð#ðÜ˜$Ÿ,™,¨Ó,ð ,°Ü˜(¨Õ+÷,ô Ÿ™›ˆ�÷,ð ,ûðñús$   Â	C ÂCÂ-C ÃCÃC ÃC)NN)Ú F)rC   rD   rE   rF   r2   rh   r!   r   r   rH   rH   ‘   s   „ Ù=ó ôH%r   rH   )r   rB   )rF   Ú
__future__r   r6   rP   r%   rW   r   rM   Údiskr   r   r   r   r&   Úobjectr,   rH   r!   r   r   ú<module>rm      sR   ðñõ &ã Û 	Û Û Û 
Û å òò,ò&ó.ôH=ˆVô =ôB>%�õ >%r   