ó Ú_e[c@sÏddlZddlmZddlmZddlmZddddgZyeWnek rrd „ZnXde fd „ƒYZ de fd „ƒYZ de fd „ƒYZ de fd „ƒYZ dS(iÿÿÿÿN(terror(ttag(ttagmapt NamedTypetOptionalNamedTypetDefaultedNamedTypet NamedTypescCsttt|ƒƒS(N(tbooltfilter(tx((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pytscBs¿eZdZeZeZdd„Zd„Zd„Z d„Z d„Z d„Z d„Z d„Zd „Zd „Zd „Zed „ƒZed „ƒZed„ƒZd„Zd„ZRS(s—Create 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|jƒS(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|jƒS(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 cBs±eZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z d „Zejd dkr—d„Zn d„Zd„Zd„Zd„Zd„Zd„Zdefd„ƒYZd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z!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¸|jr t ^q ƒ|_tg|jD]}|jr×t ^q׃|_tgt|jƒD]&\}}|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.pyR™s" !$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.pyR®s)cCs |j|kS(N(R2(RR((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pyR²scCs |j|kS(N(R2(RR((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pyRµscCs |j|kS(N(R2(RR((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pyR¸scCs |j|kS(N(R2(RR((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pyR»scCs |j|kS(N(R2(RR((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pyR¾scCs |j|kS(N(R2(RR((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pyRÁscCs t|jƒS(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„|jDƒS(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.pytvaluesàscCs|jS(N(RF(R((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pytkeysãscCs|jS(N(RI(R((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pytitemsæscCs|j|jŒS(N(RR2(R((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pytcloneéstPostponedErrorcBseZd„Zd„ZRS(cCs ||_dS(N(t_PostponedError__errorMsg(RterrorMsg((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pyRíscCstj|jƒ‚dS(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.pyRZìs cCs™i}xŒt|jƒD]{\}}|jj}t|tjƒrD|S|sPqnx>|jD]3}||krƒtjd||fƒS|||tjdƒ‚nXdS(s­Return 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.pytgetPositionNearType–s cCs~d}xe|jD]Z}|j}y |j}Wntk rH|j}nX|dksa||kr|}qqW|p}tjƒS(N(R-R2Rt minTagSettAttributeErrorRoRtTagSet(RRuRLRRo((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pyt__computeMinTagSet·s     cCs|jS(sŽReturn 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.pyRuÇs cCsði}i}d}xÈ|jD]½}|jj}t|tjƒrD|SxG|D]?}|r}||kr}tjd|||fƒS|j|| Choice (R?(R((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pyR_ëscCs|jS(s¦Return 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|jƒS(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~RR€RJR�(((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pyRtsP$                           !  (R‚tpyasn1Rt pyasn1.typeRRt__all__R@t NameErrorR„RRRR(((s7/tmp/pip-install-KP2Jbq/pyasn1/pyasn1/type/namedtype.pyts     Q