mò &á¸Ec@s˜dZddd!Zdfd„ƒYZdefd„ƒYZdefd „ƒYZd efd „ƒYZd efd „ƒYZdefd„ƒYZdS(s5$Id: Lazy.py 40218 2005-11-18 14:39:19Z andreasjung $s$Revision: 1.9 $i iþÿÿÿtLazycBs8tZdZd„Zd„Zd„Zd„ZeZRS(NicCs t|ƒ S(N(tlisttself(R((t5/data/zmath/zope/lib/python/Products/ZCatalog/Lazy.pyt__repr__scCsiy |iSWntj onXt|iƒ}x2y|||d}Wq3||_|Sq3Xq3WdS(Ni(Rt_lentAttributeErrortlent_datatl(RR ((Rt__len__s  cCs0t|tƒptdƒ‚nt||gƒS(Ns9Can not concatenate objects. Both must be lazy sequences.(t isinstancetotherRt TypeErrortLazyCatR(RR ((Rt__add__'scCsSg}xFt||ƒD]5}y|i||ƒWqtj o |SqXqW|S(N(trtxrangeti1ti2titappendRt IndexError(RRRRR((Rt __getslice__-s (t__name__t __module__t*__allow_access_to_unprotected_subobjects__RR RRtslice(((RRs     RcBs&tZdd„Zd„Zd„ZRS(NcCs§t|ƒdjoRg}x?|D]7}t|tƒo|i|iƒq |i|ƒq W|}n||_g|_ d|_ d|_ |dj o ||_ndS(Nidiiÿÿÿÿ(Rt sequencest flattened_seqtsR Rtextendt_seqRRRt_sindext_eindextlengthtNoneR(RRR#RR((Rt__init__:s      c Cs–|i} y |i}Wntj o| |SnX|}|djot|ƒ|}n|djo t |‚nt| ƒ}||jo | |Sn|d}|i }y||}Wnt |‚nX|i}x«||joy/|d}||}| i|ƒ|d}WqÚt j o[|d|_ }y|i|}Wn"|`|` |`t |‚nXd|_}qÚXqÚW||_| |S(Niiiÿÿÿÿ(RRtdataR tseqRtindexRRRtindR!tsindexRR"teindextvR( RR(R*R'R+RRR,R)R&((Rt __getitem__NsN                 cCsyy |iSWngy.d}x!|iD]}|t|ƒ7}q$WWn"tj ot|iƒ}nX||_|SnXdS(Ni(RRR R RRRR(RRR ((RR rs   (RRR$R%R-R (((RR6s  $tLazyMapcBstZdd„Zd„ZRS(NcCsH||_g|_||_|dj o ||_nt |ƒ|_dS(N( R'RR Rtfunct_funcR#R$RR(RR/R'R#((RR%…s     cCs|i}y |i}Wntj o||SnX|}|djot|ƒ|}n|djo t |‚nt|ƒ}||jo ||Sn|d}|i }xb||joTy%|d}|i |||ƒƒWq°t j o|` |`t |‚q°Xq°W||S(Nii(RRR&R RRR(RRRR)R0R/R(RR(RRR/R)R&((RR-Œs2           (RRR$R%R-(((RR.s t LazyFiltercBstZd„Zd„ZRS(NcCs(||_g|_d|_||_dS(Niÿÿÿÿ(R'RR RR"ttestt_test(RR2R'((RR%ªs   c CsM|i}y |i}Wntj o||SnX|}|djot|ƒ|}n|djo t |‚nt|ƒ}||jo ||Sn|d}|i }|i }xƒ||jouy@|d}||}||ƒo|i|ƒ|d}nWq¹t j o"|` |`|` t |‚q¹Xq¹W||_ ||S(Nii(RRR&R RRR(RRRR)R3R2R"teR,R( RR(RR2RR,R)R4R&((RR-°s>                (RRR%R-(((RR1¥s tLazyMopcBstZd„Zd„ZRS(NcCs(||_g|_d|_||_dS(Niÿÿÿÿ(R'RR RR"R2R3(RR2R'((RR%Ôs   c CsV|i}y |i}Wntj o||SnX|}|djot|ƒ|}n|djo t |‚nt|ƒ}||jo ||Sn|d}|i }|i }xŒ||jo~yI|d}||}y'||ƒ}|i|ƒ|d}WnnXWq¹t j o"|` |`|` t |‚q¹Xq¹W||_ ||S(Nii(RRR&R RRR(RRRR)R3R2R"R4R,R( RR(RR2RR,R)R4R&((RR-ÚsD                (RRR%R-(((RR5Ïs t LazyValuescBs8tZdZd„Zd„Zd„Zd„ZeZRS(soGiven a sequence of two tuples typically (key, value) act as though we are just a list of the values lazilycCs ||_dS(N(R'RR (RR'((RR%ÿscCs t|iƒS(N(RRR (R((RR scCs|i|dS(Ni(RR R((RR(((RR-scCs|i|i||!ƒS(N(Rt __class__R tstarttend(RR8R9((RRs(RRt__doc__R%R R-RR(((RR6ûs     N(R:t __version__RRR.R1R5R6(R5RR.RR6R;R:R1((Rt? s %K$*,