a _b@sBddlmZddlmZeZGdddeZGdddeZdS))absolute_import zip_longestc@s"eZdZdZddeefddZdS)itemnodez{ Dictionary key:value items wrapped in a node to be members of itemlist, the doubly linked list defined below. NcCs||_||_||_||_dSN)prevnextkeyvalue)selfrrr r r @/tmp/pip-target-4jja1joz/lib/python/orderedmultidict/itemlist.py__init__szitemnode.__init__)__name__ __module__ __qualname____doc___absentrr r r r rsrc@seZdZdZgfddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZddZddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*S)+itemlistz Doubly linked list of itemnodes. This class is used as the key:value item storage of orderedmultidict. Methods below were only added as needed for use with orderedmultidict, so some otherwise common list methods may be missing. cCs>t|_|j|j_|j_d|_|D]\}}|||q$dSNr)rrootrrsizeappend)r itemsr r r r r r,s  zitemlist.__init__cCsN|jj|jur|jjn|j}t||j||d}||_||j_|jd7_|S)N)r r )rrrrr)r r r tailnoder r r r4s zitemlist.appendcCs&|j|j_|j|j_|jd8_|S)Nr)rrr)r rr r r removenode<s  zitemlist.removenodecCs|D]\}}}||q|Srrr rr r r r r clearBs zitemlist.clearcCs t|Sr)list iteritemsr r r r rGszitemlist.itemscCs t|Sr)r!iterkeysr#r r r keysJsz itemlist.keyscCs t|Sr)r! itervaluesr#r r r valuesMszitemlist.valuesccs|D]\}}}||fVqdSrr rr r r r"Pszitemlist.iteritemsccs|D]\}}}|VqdSrr rr r r r$Tszitemlist.iterkeysccs|D]\}}}|VqdSrr rr r r r&Xszitemlist.itervaluescCs@|D]\}}}|j|j|_|_q|jj|jj|j_|j_|Sr)rrrrr r r reverse\szitemlist.reversecCs|jSrrr#r r r __len__bszitemlist.__len__ccs6|jj}|r2||jur2|j}||j|jfV|}qdSr)rrr r )r currentZnextnoder r r __iter__es zitemlist.__iter__cCst}}}t|drNt|jrNt|dkr6|\}}qRt|dkrR|\}}}n|}|tusft||fvr|D]8\}}}|tur||kr||ks|turj||krjdSqjdS)ze Params: item: Can either be a (key,value) tuple or an itemnode reference. r*TF)rhasattrcallabler*len)r itemrr r ZselfnodeZselfkeyZ selfvaluer r r __contains__ps      zitemlist.__contains__cCsH|dkr|jj|jur|jjS|dkr<|jj|jur<|jjSt|dS)Nr)rrr IndexErrorr indexr r r __getitem__s zitemlist.__getitem__cCs|||dSrrr6r r r __delitem__szitemlist.__delitem__cCs:t||D]*\\}}}\}}}||ks.||kr dSq dS)NFTr)r otherZn1key1Zvalue1Zn2key2Zvalue2r r r __eq__szitemlist.__eq__cCs || Sr)r=)r r:r r r __ne__szitemlist.__ne__cCs |jdkSrr)r#r r r __nonzero__szitemlist.__nonzero__cCs d|S)Nz[%s])rr#r r r __str__szitemlist.__str__N)rrrrrrrr rr%r'r"r$r&r(r*r,r3r8r9r=r>r?r@r r r r r"s*   rN) __future__rZ six.movesrobjectrrrr r r r  s