ó
QŽfXc           @   s©   d  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 e f d „  ƒ  YZ d	 e f d
 „  ƒ  YZ d S(   sE   
Helpers for logging.

This module needs much love to become useful.
iÿÿÿÿN(   t   mkdirpc         C   s+   t  j j d ƒ r# t d |  d ƒ S|  Sd S(   s¢   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
    t   wini    gš™™™™™¹?N(   t   syst   platformt
   startswitht   max(   t   t(    (    sb   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/joblib2/logger.pyt   _squeeze_time   s    c         C   s   t  |  ƒ }  d |  |  d f S(   Ns   %.1fs, %.1fming      N@(   R   (   R   (    (    sb   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/joblib2/logger.pyt   format_time    s    c         C   s0   t  |  ƒ }  |  d k r$ d |  d Sd |  Sd  S(   Ni<   s   %4.1fming      N@s    %5.1fs(   R   (   R   (    (    sb   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/joblib2/logger.pyt   short_format_time%   s    t   Loggerc           B   s8   e  Z d  Z d d „ Z d „  Z d „  Z d d „ Z RS(   s&    Base class for logging messages.
    i   c         C   s   | |  _  d S(   s†   
            Parameters
            ----------
            depth: int, optional
                The depth of objects printed.
        N(   t   depth(   t   selfR   (    (    sb   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/joblib2/logger.pyt   __init__4   s    c         C   s   t  j d |  | f ƒ d  S(   Ns   [%s]: %s(   t   loggingt   warn(   R   t   msg(    (    sb   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/joblib2/logger.pyR   =   s    c         C   s   t  j d |  | f ƒ d  S(   Ns   [%s]: %s(   R   t   debug(   R   R   (    (    sb   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/joblib2/logger.pyR   @   s    i    c         C   s„   d t  j k rF d d l } | j ƒ  } | j d d d d d d	 ƒ n d } t j | d
 |  j d | ƒ} | r€ | j |   n  | S(   s;    Return the formated representation of the object.
        t   numpyiÿÿÿÿNt	   precisioni   t	   thresholdi@   t	   edgeitemsi   R   t   indent(	   R   t   modulesR   t   get_printoptionst   set_printoptionst   Nonet   pprintt   pformatR   (   R   t   objR   t   npt   print_optionst   out(    (    sb   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/joblib2/logger.pyt   formatD   s    (   t   __name__t
   __module__t   __doc__R   R   R   R!   (    (    (    sb   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/joblib2/logger.pyR
   0   s
   			t	   PrintTimec           B   s,   e  Z d  Z d d d „ Z d e d „ Z RS(   s9    Print and log messages while keeping track of time.
    c         C   sl  | d  k	 r' | d  k	 r' t d ƒ ‚ n  t j ƒ  |  _ |  j |  _ | d  k	 rf t j j | d ƒ } n  | |  _ | d  k	 rht	 t j j
 | ƒ ƒ t j j | ƒ rxI t d d ƒ D]8 } y( t j | d | | d | d ƒ Wq³ q³ Xq³ Wy t j | | d ƒ WqqXn  yG t | d ƒ } | j d ƒ | j d	 t j |  j ƒ ƒ | j ƒ  WqhqhXn  d  S(
   Ns&   Cannot specify both logfile and logdirs
   joblib.logi   i	   s   .%is   .1t   ws   
Logging joblib python script
s
   
---%s---
(   R   t
   ValueErrort   timet	   last_timet
   start_timet   ost   patht   joint   logfileR    t   dirnamet   existst   xranget   shutilt   movet   copyt   opent   writet   ctimet   close(   R   R.   t   logdirt   i(    (    sb   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/joblib2/logger.pyR   Z   s6    	t    c         C   s²   | s2 t  j  ƒ  |  j } d | t | ƒ f } n* t  j  ƒ  |  j } d | | | d f } t j | IJ|  j d k	 rŸ y t |  j d ƒ | IJWqŸ qŸ Xn  t  j  ƒ  |  _ d S(   sr    Print the time elapsed between the last call and the current
            call, with an optional message.
        s   %s: %ss   %s: %.2fs, %.1f mini<   t   aN(	   R(   R)   R   R*   R   t   stderrR.   R   t   file(   R   R   t   totalt
   time_lapset   full_msg(    (    sb   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/joblib2/logger.pyt   __call__€   s    	N(   R"   R#   R$   R   R   t   FalseRB   (    (    (    sb   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/joblib2/logger.pyR%   V   s   &(   R$   R(   R   R+   R2   R   R   t   diskR    R   R   R	   t   objectR
   R%   (    (    (    sb   /oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.14.0-Linux/share/spades/joblib2/logger.pyt   <module>   s   			&