Ñò i'dWc @sÖdZddkZddklZddklZddkZddklZl Z l Z ddk l Z l Z ddklZddklZd efd „ƒYZd efd „ƒYZd efd„ƒYZdS(s private: classes used by the individual State implementations and NVList. NVPair: wrapper around nvpairp. NVPairIterator: Iterator for all NVList states. next() returns NVPair objects. NVKeysIterator: Iteratoer for all NVList states. next() returns a tuple of (str, int) where str is the name, and int is in DATA_TYPES. State: provide the (abstract) base class for NVLIterator, NVLDictionary, NVLTupleDictionary. State is where __del__ is implemented. If a State object is garbage collected, the nvlist_t it is holding onto will have nvlist_free called on it. This means that NVPair should hang on to a reference to the State object that created it. Same for any NVList returned from an NVPair, or any other means, e.g. __getitem__(). ALL reference tracking happens in this module alone. iÿÿÿÿN(tIterator(tEINVAL(t DATA_TYPE_MAPtDATA_TYPE_NVLISTtDATA_TYPE_NVLIST_ARRAY(tnvlistptnvpairp(tcfunc(tVALUEtNVPaircBsVeZdZd„Zed„ƒZed„ƒZed„ƒZd„Zd„Z RS(sclass to wrap nvpairpcCsVt|tƒptdƒ‚nt|tƒptdƒ‚n||_||_dS(Ns(state must be a libnvpair.abstract.StatesNVPair must be given an nvpairp(t isinstancetStatet TypeErrorRt_statet_as_parameter_(tselftstatetnvp((s ../private.pyt__init__Es  cCs ti|ƒS(s(name of this NVPair, always an ASCII str(Rt nvpair_name(R((s ../private.pytnamePscCs-t|dƒpti|ƒ|_n|iS(s<datatype of this NVPair, an int in libnvpair.const.DATA_TYPEt _datatype(thasattrRt nvpair_typeR(R((s ../private.pytdatatypeUscCsht|i|ƒ}|itjo|i|_n2|itjo!x|D]}|i|_qJWn|S(svalue stored in NVPair(RRRR t_refR(Rtresulttelem((s ../private.pytvalue]scCs`ti||ƒ}|djo=|tjotdƒ‚nt|dti|ƒƒ‚ndS(Nis(nvlist_remove_nvpair(): invalid argumentsnvlist_remove_nvpair(): %s(Rtnvlist_remove_nvpairRR tOSErrortoststrerror(Rtnvlterr((s ../private.pytremovehs    cCsd|it|i|ifS(sx.__repr__() <==> repr(x)sNVPair: %s <%s> = %s(RRRR(R((s ../private.pyt__repr__ps  ( t__name__t __module__t__doc__RtpropertyRRRR#R$(((s ../private.pyR Bs  tNVPairIteratorcBs#eZdZed„Zd„ZRS(s@class to manage iterating over the _NVPair objects in an NVList.cCswt|tƒptdƒ‚nt|tƒptdƒ‚n||_d|_htit 6ti t 6||_ dS(Ns(state must be a libnvpair.abstract.Statesforward must be a bool( R R R tboolR tNonet_invpRtnvlist_next_nvpairtTruetnvlist_prev_nvpairtFalset _function(RRtforward((s ../private.pyRzs   cCsK|i|i|iƒ|_|ip tƒ‚nt|i|iƒ}|S(s2x.next() -> the next value, or raise StopIteration(R1R R,t StopIterationR (Rtpair((s ../private.pytnextˆs   (R%R&R'R.RR5(((s ../private.pyR)xs R cBseZdZeiZd d„Zd„Zei d„ƒZ ei d„ƒZ ei d„ƒZ ei d„ƒZd„Zei d„ƒZRS( sª Abstract Base Class for all the NVList states. The state is determined by the flags of the NVList. State does not change, it is set at allocation time. cCs@t|tƒptdƒ‚n||_t|dƒ |_dS(Ns$NVLIterator must be given an nvlistpR(R RR RRt_track(Rtnvlp((s ../private.pyR›s cCs(|ioti|ƒnd|_dS(N(R6Rt nvlist_freeR+R(R((s ../private.pyt__del__¡s cCs t‚dS(N(tNotImplementedError(R((s ../private.pytflags¨scCs t‚dS(N(R:(RtkeyR((s ../private.pyt __setitem__¬scCs t‚dS(N(R:(RR<((s ../private.pyt __delitem__°scCsdS(s+__getitem_helper__(key) -> result, datatypeN((RR<((s ../private.pyt__getitem_helper_state__´scsL‡fd†}ˆi|ƒ}g}|D]\}}||||ƒq)~S(s+__getitem_helper__(key) -> result, datatypecsO|tjo ˆ|_n,|tjox|D]}ˆ|_q.Wn||fS(N(RRR(RRR(R(s ../private.pytfixitem¿s   (R?(RR<R@Rt_[1]RR((Rs ../private.pyt__getitem_helper__¹scCs t‚dS(N(R:(RR<tdefault((s ../private.pyt__pop_helper__ÊsN(R%R&R'tabctABCMetat __metaclass__R+RR9tabstractpropertyR;tabstractmethodR=R>R?RBRD(((s ../private.pyR ‘s    (R'REt collectionsRterrnoRRtlibnvpair.constRRRtlibnvpair.cstructRRt libnvpairRtlibnvpair.valueRtobjectR R)R (((s ../private.pyt4s  6