a _ÆbDã@s0ddlmZddlmZmZGdd„deƒZdS)é)Úomdicté)Úis_iterable_but_not_stringÚabsentc@s8eZdZdZdd„Zdd„Zdd„Zdd „Zd d „Zd S) Úomdict1DaI One dimensional ordered multivalue dictionary. Whenever a list of values is passed to set(), __setitem__(), add(), update(), or updateall(), it's treated as multiple values and the appropriate 'list' method is called on that list, like setlist() or addlist(). For example: omd = omdict1D() omd[1] = [1,2,3] omd[1] != [1,2,3] # True. omd[1] == 1 # True. omd.getlist(1) == [1,2,3] # True. omd.add(2, [2,3,4]) omd[2] != [2,3,4] # True. omd[2] == 2 # True. omd.getlist(2) == [2,3,4] # True. omd.update([(3, [3,4,5])]) omd[3] != [3,4,5] # True. omd[3] == 3 # True. omd.getlist(3) == [3,4,5] # True. omd = omdict([(1,None),(2,None)]) omd.updateall([(1,[1,11]), (2,[2,22])]) omd.allitems == [(1,1), (1,11), (2,2), (2,22)] cCsNt|ƒs|g}|r"|j |tƒ¡|D]"}|j ||¡}|j| |¡q&|S©N)rÚ_mapÚ setdefaultÚlistZ_itemsÚappend)ÚselfÚkeyÚvalueÚvalÚnode©rú4/tmp/pip-target-4jja1joz/lib/python/furl/omdict1D.pyÚadd1sz omdict1D.addcCs | ||¡Sr©Ú_set©r r rrrrÚset>sz omdict1D.setcCs | ||¡SrrrrrrÚ __setitem__Aszomdict1D.__setitem__csÞ|D]Ô\‰}t|ƒ}|r |r&|s&|g}|D]¬}|gkrZg|ˆ<‡fdd„|Dƒ|dd…<q*ˆ|vr‚| ˆt¡gtfvr‚|g|ˆ<q*ˆ|vr¸|s¸t|ˆƒt| ˆ¡ƒkr¸|ˆ |¡q*|rÈ|g|ˆ<q*| ˆ|f¡q*qdS)zï Subclassed from omdict._bin_update_items() to make update() and updateall() process lists of values as multiple values. and are modified directly, ala pass by reference. csg|]}ˆ|dkr|‘qS)rr)Ú.0Úlst©r rrÚ [óz.omdict1D._bin_update_items..N)rÚgetÚ_absentÚlenÚvaluesr )r ÚitemsZreplace_at_most_oneÚ replacementsZ leftoversr!Zlike_list_not_strrrrrÚ_bin_update_itemsDs&  ÿ  ÿ zomdict1D._bin_update_itemscCst|ƒs|g}| ||¡|Sr)rZsetlistrrrrrks z omdict1D._setN) Ú__name__Ú __module__Ú __qualname__Ú__doc__rrrr$rrrrrrs  'rN)ZorderedmultidictrÚcommonrrrrrrrrÚ s