_e[c@sddlZddlmZddlmZddlmZddddgZyeWnek rrd ZnXde fd YZ de fd YZ de fd YZ de fd YZ dS(iN(terror(ttag(ttagmapt NamedTypetOptionalNamedTypetDefaultedNamedTypet NamedTypescCsttt|S(N(tbooltfilter(tx((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pytscBseZdZeZeZddZdZdZ dZ dZ dZ dZ dZd Zd Zd Zed Zed ZedZdZdZRS(sCreate named field object for a constructed ASN.1 type. The |NamedType| object represents a single name and ASN.1 type of a constructed ASN.1 type. |NamedType| objects are immutable and duck-type Python :class:`tuple` objects holding *name* and *asn1Object* components. Parameters ---------- name: :py:class:`str` Field name asn1Object: ASN.1 type object cCs.||_||_||f|_||_dS(N(t_NamedType__namet_NamedType__typet_NamedType__nameAndTypet_NamedType__openType(tselftnamet asn1ObjecttopenType((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pyt__init__*s  cCsPd|j|jf}|jr3|d|j7}nd|jjt||fS(Ns%s=%rs openType: %rs<%s object at 0x%x type %s>(RRRt __class__t__name__tid(Rtrepresentation((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pyt__repr__0s cCs |j|kS(N(R (Rtother((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pyt__eq__8scCs |j|kS(N(R (RR((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pyt__ne__;scCs |j|kS(N(R (RR((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pyt__lt__>scCs |j|kS(N(R (RR((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pyt__le__AscCs |j|kS(N(R (RR((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pyt__gt__DscCs |j|kS(N(R (RR((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pyt__ge__GscCs t|jS(N(thashR (R((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pyt__hash__JscCs |j|S(N(R (Rtidx((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pyt __getitem__MscCs t|jS(N(titerR (R((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pyt__iter__PscCs|jS(N(R (R((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pyRSscCs|jS(N(R (R((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pyRWscCs|jS(N(R(R((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pyR[scCs|jS(N(R(R((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pytgetNameascCs|jS(N(R(R((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pytgetTypedsN(Rt __module__t__doc__tFalset isOptionalt isDefaultedtNoneRRRRRRRRR!R#R%tpropertyRRRR&R'(((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pyRs&            cBseZejZeZRS((RR(RR)tTrueR+(((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pyRhs cBseZejZeZRS((RR(RR)R/R,(((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pyRns cBseZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zejd dkrdZn dZdZdZdZdZdZdefdYZdZdZdZdZdZdZdZ dZ!d Z"d!Z#e$d"Z%d#Z&e$d$Z'e$d%Z(e$d&Z)e$d'Z*e$d(Z+e$d)Z,RS(*s+Create a collection of named fields for a constructed ASN.1 type. The NamedTypes object represents a collection of named fields of a constructed ASN.1 type. *NamedTypes* objects are immutable and duck-type Python :class:`dict` objects holding *name* as keys and ASN.1 type object as values. Parameters ---------- *namedTypes: :class:`~pyasn1.type.namedtype.NamedType` Examples -------- .. code-block:: python class Description(Sequence): ''' ASN.1 specification: Description ::= SEQUENCE { surname IA5String, first-name IA5String OPTIONAL, age INTEGER DEFAULT 40 } ''' componentType = NamedTypes( NamedType('surname', IA5String()), OptionalNamedType('first-name', IA5String()), DefaultedNamedType('age', Integer(40)) ) descr = Description() descr['surname'] = 'Smith' descr['first-name'] = 'John' cOs||_t|j|_|j|_|j|_|j|_d|kr`|j pci|_ |j dt |_ |j dt|_tg|jD]}|js|jrt ^q|_tg|jD]}|jrt ^q|_tgt|jD]&\}}|j r |j r |^q |_tg|jD]}|j^qJ|_tg|jD]}|j^qr|_tg|jD]}|j|jf^q|_dS(Ntterminaltunique(t_NamedTypes__namedTypestlent_NamedTypes__namedTypesLent_NamedTypes__computeMinTagSett_NamedTypes__minTagSett _NamedTypes__computeNameToPosMapt_NamedTypes__nameToPosMapt_NamedTypes__computeTagToPosMapt_NamedTypes__tagToPosMapt"_NamedTypes__computeAmbiguousTypest_NamedTypes__ambiguousTypest_NamedTypes__computeTagMapsR/t_NamedTypes__uniqueTagMapR*t_NamedTypes__nonUniqueTagMaptanyR,R+t!_NamedTypes__hasOptionalOrDefaultRt_NamedTypes__hasOpenTypest frozensett enumeratet_NamedTypes__requiredComponentsRt_NamedTypes__keysttupleRt_NamedTypes__valuest_NamedTypes__items(Rt namedTypestkwargst namedTypeR"tnt((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pyRs" !$B((cCsFdjg|jD]}d|^q}d|jjt||fS(Ns, s%rs<%s object at 0x%x types %s>(tjoinR2RRR(RR R((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pyRs)cCs |j|kS(N(R2(RR((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pyRscCs |j|kS(N(R2(RR((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pyRscCs |j|kS(N(R2(RR((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pyRscCs |j|kS(N(R2(RR((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pyRscCs |j|kS(N(R2(RR((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pyRscCs |j|kS(N(R2(RR((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pyRscCs t|jS(N(R R2(R((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pyR!scCs6y|j|SWn tk r1|j|j|SXdS(N(R2t TypeErrorR8(RR"((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pyR#s cCs ||jkS(N(R8(Rtkey((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pyt __contains__scCsd|jDS(Ncss|]}|dVqdS(iN((t.0R ((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pys s(R2(R((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pyR%siicCs |jdkS(Ni(R4(R((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pyt __nonzero__scCs |jdkS(Ni(R4(R((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pyt__bool__scCs|jS(N(R4(R((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pyt__len__scCs|jS(N(RH(R((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pytvaluesscCs|jS(N(RF(R((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pytkeysscCs|jS(N(RI(R((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pytitemsscCs|j|jS(N(RR2(R((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pytclonestPostponedErrorcBseZdZdZRS(cCs ||_dS(N(t_PostponedError__errorMsg(RterrorMsg((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pyRscCstj|jdS(N(Rt PyAsn1ErrorR[(Rtitem((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pyR#s(RR(RR#(((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pyRZs cCsi}xt|jD]{\}}|jj}t|tjrD|S|sPqnx>|jD]3}||krtjd||fS|||tjdnXdS(sReturn the closest field position where given ASN.1 type is allowed. Some ASN.1 serialisation allow for skipping optional and defaulted fields. Some constructed ASN.1 types allow reordering of the fields. When recovering such objects it may be important to know at which field position, in field set, given *tagSet* is allowed at or past *idx* position. Parameters ---------- tagSet: :class:`~pyasn1.type.tag.TagSet` ASN.1 type which field position to look up idx: :py:class:`int` Field position at or past which to perform ASN.1 type look up Returns ------- : :py:class:`int` Field position in fields set Raises ------ : :class:`~pyasn1.error.PyAsn1Error` If *tagSet* is not present or not unique within callee *NamedTypes* or *idx* is out of fields range sType position out of rangeN(R<RpRnRR](RRoR"((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pytgetPositionNearTypes cCs~d}xe|jD]Z}|j}y |j}Wntk rH|j}nX|dksa||kr|}qqW|p}tjS(N(R-R2Rt minTagSettAttributeErrorRoRtTagSet(RRuRLRRo((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pyt__computeMinTagSets     cCs|jS(sReturn the minimal TagSet among ASN.1 type in callee *NamedTypes*. Some ASN.1 types/serialisation protocols require ASN.1 types to be arranged based on their numerical tag value. The *minTagSet* property returns that. Returns ------- : :class:`~pyasn1.type.tagset.TagSet` Minimal TagSet among ASN.1 types in callee *NamedTypes* (R6(R((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pyRus cCsi}i}d}x|jD]}|jj}t|tjrD|SxG|D]?}|r}||kr}tjd|||fS|j|| Choice (R?(R((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pyR_scCs|jS(sReturn a *TagMap* object from unique tags and types recursively. Return a :class:`~pyasn1.type.tagmap.TagMap` object by combining tags from *TagMap* objects of children types and associating them with their immediate child type. Example ------- .. code-block:: python OuterType ::= CHOICE { innerType INTEGER } Calling *.tagMapUnique* on *OuterType* will yield a map like this: .. code-block:: python Integer.tagSet -> Choice Note ---- Duplicate *TagSet* objects found in the tree of children types would cause error. (R>(R((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pyt tagMapUniquescCs|jS(N(RA(R((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pythasOptionalOrDefault!scCs|jS(N(RB(R((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pyt hasOpenTypes%scCs t|jS(N(RGR2(R((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pyRJ)scCs|jS(N(RE(R((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pytrequiredComponents-s(-RR(R)RRRRRRRRR!R#RQR%tsyst version_infoRSRTRURVRWRXRYtobjectRZR9R7R;RmRpRqRrRsRtR5R.RuR=R_R~RRRJR(((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pyRtsP$                           !  (Rtpyasn1Rt pyasn1.typeRRt__all__R@t NameErrorRRRRR(((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pyts     Q