
    d{h	                     4    S r SSKrSSKrSSKr " S S5      rg)zBpartitions papids into bunches, for lookup of issuedates in insish    Nc                   <    \ rS rSrS
S jrS rS rS rS rS r	Sr
g	)Bunch	   c                 *    Xl         X l        S U l        g )N)e
do_verbosefudi)selferimpr   s      !/home/ernad/ernad/python/bunch.py__init__Bunch.__init__   s    $	    c                    [         R                  R                  U5      (       d  [        SU 35        [	        U5      eXl        SU R                  R                  ;  a  [        S[        R                  S9  gU R                  R                  S   U l
        U R                  S:w  a  U R                  n[        SU 35        SU R                  R                  ;  a  [        S	[        R                  S9  gU R                  R                  S   U l        0 U l        U R                  U R                  S'   U R                  U R                     U l        0 U l        g
)Nzbunch needs a directory, not F
bunch_typez$bunch need a bunch_type ernad config)fileendianz,bunch needs extending to support bunch type 
bunch_paraz$bunch need a bunch_para ernad configT)ospathisdirprint	Exceptionr	   r   confsysstderrr   r   find_forendian_findfindbunches)r
   r	   r   s      r   setupBunch.setup   s   ww}}T""1$89D/! 	tvv{{*8zz#&&++l3??h&J@MNtvv{{*8zz#&&++l3"&"2"2hMM$//2	r   c                 :    [        U R                  5      nX* S nU$ )z%para is the length to take at the endN)intr   )r
   papidcut_endbunchs       r   r   Bunch.endian_find+   s!    doo&hi r   c                     UR                  5        HF  nU R                  U5      nX0R                  ;  a  0 U R                  U'   X   U R                  U   U'   MH     g)zadds a dict to the bunchesN)keysr   r    )r
   papidsr%   r'   s       r   add	Bunch.add1   sM    [[]EIIe$ELL(&(U#)/DLL&	 #r   c                    U R                   S-   U-   S-   n[        R                  R                  U5      (       a  [        R
                  " U5      nO0 nSnU R                  U    H  nXS;  a  SnU R                  U   U   X5'   M      U(       a  [        R                  " X#5        gU R                  (       a  [        SU 35        g)z)saves a bunch (by bunchid) in a data file/z.json.gzFTzno need to save )
r	   r   r   isfilefilerloadr    dumpr   r   )r
   r'   fufidataneed_i_saver%   s         r   save
Bunch.save9   s    yy3&377>>$::d#D D\\%(E ",,u-e4DK ) JJt"__$TF+,r   c                 L    U R                    H  nU R                  U5        M     g)zsave all bunchesN)r    r7   )r
   r'   s     r   save_allBunch.save_allM   s    \\EIIe "r   )r   r   r    r   r   r   r   r	   N)F)__name__
__module____qualname____firstlineno__r   r!   r   r,   r7   r:   __static_attributes__ r   r   r   r   	   s     
67(r   r   )__doc__r   r   r1   r   rA   r   r   <module>rC      s    H 	 
 G Gr   