
    HWhW                         S r SSKJr  SSKrSSKrSSKrSSKrSSKrSSKrSSK	J
r
  S rS rS rSS	 jr " S
 S\5      r " S S\5      rg)zE
Helpers for logging.

This module needs much love to become useful.
    )print_functionN   )mkdirpc                 l    [         R                  R                  S5      (       a  [        SU S-
  5      $ U $ )zRemove .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    //usr/lib/python3/dist-packages/joblib/logger.py_squeeze_timer      s.    
 ||u%%1a"f~    c                 *    [        U 5      n SX S-  4-  $ )Nz%.1fs, %.1fmin      N@r   r   s    r   format_timer   "   s    aAqc'l**r   c                 >    [        U 5      n U S:  a  SU S-  -  $ SU -  $ )N<   z%4.1fminr   z %5.1fsr   r   s    r   short_format_timer   '   s,    aA2vQW%%Ar   c                     S[         R                  ;   a&  SS KnUR                  5       nUR	                  SSSS9  OS n[
        R                  " XUS9nU(       a  WR                  " S0 UD6  U$ )	Nnumpyr      @   r   )	precision	threshold	edgeitems)depthindent )r   modulesr   get_printoptionsset_printoptionspprintpformat)objr    r   npprint_optionsouts         r   r&   r&   /   sb    #++++-
a2C
..&
9C
,m,Jr   c                   >    \ rS rSrSrS
S jrS rS rS rSS jr	S	r
g)Logger?   z%Base class for logging messages.
    Nc                 :    Xl         U(       a  X l        gSU l        g)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__Logger.__init__C   s     
!T
x
r   c                 r    [         R                  " U R                  5      R                  SU < SU< 35        g N[z]: )logging	getLoggerr0   warningr1   msgs     r   warnLogger.warnO   s$    $**%--D#.FGr   c                 @    [         R                  " SU < SU< 35        g r6   )r8   infor;   s     r   r@   Logger.infoR   s    4-.r   c                 r    [         R                  " U R                  5      R                  SU < SU< 35        g r6   )r8   r9   r0   debugr;   s     r   rC   Logger.debugU   s$    $**%++$,DEr   c                 *    [        XU R                  S9$ )z2Return the formatted representation of the object.)r    r   )r&   r   )r1   r'   r    s      r   formatLogger.formatY   s    s<<r   )r0   r   )   N)r   )__name__
__module____qualname____firstlineno____doc__r3   r=   r@   rC   rF   __static_attributes__r!   r   r   r,   r,   ?   s"    
0H/F=r   r,   c                   ,    \ rS rSrSrSS jrSS jrSrg)		PrintTimea   z8Print and log messages while keeping track of time.
    Nc                    Ub  Ub  [        S5      e[        R                  " 5       U l        U R                  U l        Ub   [        R
                  R                  US5      nXl        Ub  [        [        R
                  R                  U5      5        [        R
                  R                  U5      (       aT  [        SS5       H*  n [        R                  " USU-  -   USUS-   -  -   5        M,      [        R                  " XS-   5         [        US5       nUR!                  S5        UR!                  S	[        R"                  " U R                  5      -  5        S S S 5        g g !    M  = f!    Ng= f! , (       d  f       g = f!    g = f)
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)r1   r\   logdiris       r   r3   PrintTime.__init__e   s=   6#5EFF..ggll6<8G277??7+,ww~~g&&q!A1Geai$7$+eq1uo$=? %-KK48'3'7MM"DEMM.4::dnn3M"MN ('# 10
-,''sC   &E$0E, 
F AE3F $E),E03
F=F F Fc                    U(       d5  [         R                   " 5       U R                  -
  nU< S[        U5      < 3nO,[         R                   " 5       U R                  -
  nSXUS-  4-  n[	        U[
        R                  S9  U R                  b)   [        U R                  S5       n[	        XES9  SSS5        [         R                   " 5       U l        g! , (       d  f       N)= f!    N0= f)z]Print the time elapsed between the last call and the current
call, with an optional message.
z: z%s: %.2fs, %.1f minr   )fileNa)	rV   rW   r   rX   printr   stderrr\   rc   )r1   r<   total
time_lapsefull_msgfs         r   __call__PrintTime.__call__   s     t~~5J#&J(?@H t6J,0:R0A AHhSZZ(<<#$,,,(+ -  -,s*   C# %
C/C# 
C C#  C# #C')rW   r\   rX   )NN) F)rI   rJ   rK   rL   rM   r3   rr   rN   r!   r   r   rP   rP   a   s    !J%r   rP   )r   rH   )rM   
__future__r   rV   r   rY   r`   r8   r%   diskr   r   r   r   r&   objectr,   rP   r!   r   r   <module>rx      sS    &  
 	    +

 =V =DA% A%r   