
    4ef                     0    d dl Z d dlZ G d d          ZdS )    Nc                   2    e Zd ZdZd Zd	dZd Zd Zd ZdS )
Otriaz+basic functions for a collection of reportsc                 j    || _         g | _        |j        D ]}| j                            |           d S N)eliveappend)selferimprepcodes      !/home/ernad/ernad/python/otria.py__init__zOtria.__init__
   sA    	 z 	& 	&GIW%%%%t    Fc                 6   | j         }g }i }| j        D ]}|j        |         }|j        d         }|j                            |          }||                    |           N|j                            |          }	|j        d         }
|j        	                    |
|	          }t          j                            |          dd         }t          |          dk    r)d|	 }|d| z  }t          |t          j                   |||<   g }|D ](}|dd         }|||vr|                    |           )t#          |d	
          }g }|D ]e}g }|D ]0}|dd         }||k    r|                    |dd                    1t#          |          }|D ]}|                    | d|            fg }|r |D ]}t          |dz   ||         z              |D ]$}|                    ||                    || _        %|D ]}|                    |           |S )Nsentselectedr      zno selected at sent z in )file
   T)reverse   _ )r   r   reportstaged	very_lastr	   f	issuedatelast_by_issuedateospathbasenamelenprintsysstderrsortedsorted_by_timely)r
   
do_verboser   natal_reportsrepcode_critsr   r   sent_dirlast_sent_fufilast_sent_issuedateselected_dir	crit_fufi	crit_banamsgfound_issuedatescritfound_issuedatesorted_issuedatessorted_crits	sub_critsthis_found_issuedatesub_critsorted_repcodess                          r   	by_timelyzOtria.by_timely   s   Fy 	/ 	/GXg&F|F+HS]]844N%$$W---"##--"?"?!<
3L--l.AC CI((33AbD9I9~~""B-@BB'g'''c
++++'.M)$$! 	9 	9D"1R4jO&&666 ''888"#3TBBB0 		E 		EOI% . .'+AbDz$'?::  be----y))I% E E##$C$C$C$CDDDDE 	8$ 8 8dSj=#667777  	4 	4D""=#6777$3D!!$ 	, 	,G""7++++r   c                    i ddl m}  || j                  | _         | j        D ]G}| j                             |d          }|d|<   %t
          j                            |          |<   Ht          | j        fd          }|S )Nr   )Moclatrainc                     |          S r    )xcritss    r   <lambda>z%Otria.by_train_size.<locals>.<lambda>T   s    %( r   )key)	moclar?   r   r   findr!   r"   getsizer(   )r
   r?   r   
train_fufir<   rD   s        @r   by_train_sizezOtria.by_train_sizeJ   s    U46]]
y 	= 	=G'::J!!"g!#!<!<g 0B0B0B0BCCCr   c                    | j         }t          | d          s|                                  g }g }| j        D ]}|j        |                             d          }||                    |           :|j        |                             dd          }||                    |           tt          j        	                    |          }t          j        	                    |          }||k    r|                    |           Ό| j        D ]A}||v r||v r|j        |         
                                r,|                    |           B|S )Nr)   r   modelz*.model)kind)r   hasattrr=   r)   r   lastr	   r!   r"   getmtimehas_it_labour)	r
   r   skippedorderedr   	last_sent
last_modellast_model_mtimelast_sent_mtimes	            r   by_model_urgezOtria.by_model_urgeW   so   Ft/00 	NN, 	 	G)..v66I w''''*//i/HHJ!w'''!w//
;; g..y99O/11w''' 2 , 	$ 	$G'!!'!!x ..00 NN7####r   c                     |                                  }t          |          }|dz   }i }d}|D ]}|dz  }||z
  |z  ||<   |S )zGcaculates a fraction to add to numbers to prioritize high otria reportsg?r      )r=   r$   )r
   repcodestotal
total_plusoutpositionr   s          r   to_fractionzOtria.to_fraction}   sa    >>##HS[
 	; 	;GMH!H,
:CLL
r   N)F)	__name__
__module____qualname____doc__r   r=   rK   rY   ra   rB   r   r   r   r      sl        55  5 5 5 5n    L
 
 
 
 
r   r   )r&   r!   r   rB   r   r   <module>rf      sS    



 				@ @ @ @ @ @ @ @ @ @r   