ó ‘ee[c @s%ddlmZmZddlmZmZmZddlmZmZm Z m Z ddl m Z dZ dZdZdZd Zd Zd Zd Zd ZdZedddddddeeee e gƒZee jfZdefd„ƒYZdefd„ƒYZdefd„ƒYZdS(iÿÿÿÿ(tMappingtSet(tDecimaltContexttClamped(tOverflowtInexactt UnderflowtRounded(tsixtStNtBtSStNStBStNULLtBOOLtMtLtEmini€ÿÿÿtEmaxi~tpreci&ttrapstBinarycBsDeZdZd„Zd„Zd„Zd„Zd„Zd„ZRS(sûA class for representing Binary in dynamodb Especially for Python 2, use this class to explicitly specify binary data for item in DynamoDB. It is essentially a wrapper around binary. Unicode and Python 3 string types are not allowed. cCsQt|tƒsDtddjgtD]}t|ƒ^q"ƒƒ‚n||_dS(Ns)Value must be of the following types: %s.s, (t isinstancet BINARY_TYPESt TypeErrortjointstrtvalue(tselfRtt((s5/tmp/pip-install-xdEqop/boto3/boto3/dynamodb/types.pyt__init__/s/cCs,t|tƒr|j|jkS|j|kS(N(RRR(Rtother((s5/tmp/pip-install-xdEqop/boto3/boto3/dynamodb/types.pyt__eq__5scCs|j|ƒ S(N(R#(RR"((s5/tmp/pip-install-xdEqop/boto3/boto3/dynamodb/types.pyt__ne__:scCs d|jS(Ns Binary(%r)(R(R((s5/tmp/pip-install-xdEqop/boto3/boto3/dynamodb/types.pyt__repr__=scCs|jS(N(R(R((s5/tmp/pip-install-xdEqop/boto3/boto3/dynamodb/types.pyt__str__@scCs t|jƒS(N(thashR(R((s5/tmp/pip-install-xdEqop/boto3/boto3/dynamodb/types.pyt__hash__Cs( t__name__t __module__t__doc__R!R#R$R%R&R((((s5/tmp/pip-install-xdEqop/boto3/boto3/dynamodb/types.pyR(s     tTypeSerializercBsËeZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z d „Zd „Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„ZRS(s:This class serializes Python data types to DynamoDB types.cCs9|j|ƒ}t|d|jƒƒ}i||ƒ|6S(sœThe method to serialize the Python data types. :param value: A python value to be serialized to DynamoDB. Here are the various conversions: Python DynamoDB ------ -------- None {'NULL': True} True/False {'BOOL': True/False} int/Decimal {'N': str(value)} string {'S': string} Binary/bytearray/bytes (py3 only) {'B': bytes} set([int/Decimal]) {'NS': [str(value)]} set([string]) {'SS': [string]) set([Binary/bytearray/bytes]) {'BS': [bytes]} list {'L': list} dict {'M': dict} For types that involve numbers, it is recommended that ``Decimal`` objects are used to be able to round-trip the Python type. For types that involve binary, it is recommended that ``Binary`` objects are used to be able to round-trip the Python type. :rtype: dict :returns: A dictionary that represents a dynamoDB data type. These dictionaries can be directly passed to botocore methods. s _serialize_%s(t_get_dynamodb_typetgetattrtlower(RRt dynamodb_typet serializer((s5/tmp/pip-install-xdEqop/boto3/boto3/dynamodb/types.pyt serializeIscCs.d}|j|ƒrt}n |j|ƒr6t}nô|j|ƒrNt}nÜ|j|ƒrft}nÄ|j |ƒr~t }n¬|j ||jƒrœt }nŽ|j ||jƒrºt }np|j ||j ƒrØt}nR|j|ƒrðt}n:|j|ƒrt}n"dt|ƒ|f}t|ƒ‚|S(Ns$Unsupported type "%s" for value "%s"(tNonet_is_nullRt _is_booleantBOOLEANt _is_numbertNUMBERt _is_stringtSTRINGt _is_binarytBINARYt _is_type_sett NUMBER_SETt STRING_SETt BINARY_SETt_is_maptMAPt_is_listtLISTttypeR(RRR0tmsg((s5/tmp/pip-install-xdEqop/boto3/boto3/dynamodb/types.pyR-is0           cCs|dkrtStS(N(R3tTruetFalse(RR((s5/tmp/pip-install-xdEqop/boto3/boto3/dynamodb/types.pyR4s cCst|tƒrtStS(N(RtboolRGRH(RR((s5/tmp/pip-install-xdEqop/boto3/boto3/dynamodb/types.pyR5•scCs>t|tjtfƒrtSt|tƒr:tdƒ‚ntS(Ns9Float types are not supported. Use Decimal types instead.(RR t integer_typesRRGtfloatRRH(RR((s5/tmp/pip-install-xdEqop/boto3/boto3/dynamodb/types.pyR7šs  cCst|tjƒrtStS(N(RR t string_typesRGRH(RR((s5/tmp/pip-install-xdEqop/boto3/boto3/dynamodb/types.pyR9¢scCsIt|tƒrtSt|tƒr&tStjrEt|tjƒrEtStS(N(RRRGt bytearrayR tPY3t binary_typeRH(RR((s5/tmp/pip-install-xdEqop/boto3/boto3/dynamodb/types.pyR;§scCst|tƒrtStS(N(RRRGRH(RR((s5/tmp/pip-install-xdEqop/boto3/boto3/dynamodb/types.pyt_is_set°scCs/|j|ƒr+tt||ƒkr+tSntS(N(RPRHtmapRG(RRttype_validator((s5/tmp/pip-install-xdEqop/boto3/boto3/dynamodb/types.pyR=µscCst|tƒrtStS(N(RRRGRH(RR((s5/tmp/pip-install-xdEqop/boto3/boto3/dynamodb/types.pyRA»scCst|tƒrtStS(N(RtlistRGRH(RR((s5/tmp/pip-install-xdEqop/boto3/boto3/dynamodb/types.pyRCÀscCstS(N(RG(RR((s5/tmp/pip-install-xdEqop/boto3/boto3/dynamodb/types.pyt_serialize_nullÅscCs|S(N((RR((s5/tmp/pip-install-xdEqop/boto3/boto3/dynamodb/types.pyt_serialize_boolÈscCs4ttj|ƒƒ}|dkr0tdƒ‚n|S(NtInfinitytNaNsInfinity and NaN not supported(sInfinitysNaN(RtDYNAMODB_CONTEXTtcreate_decimalR(RRtnumber((s5/tmp/pip-install-xdEqop/boto3/boto3/dynamodb/types.pyt _serialize_nËs cCs|S(N((RR((s5/tmp/pip-install-xdEqop/boto3/boto3/dynamodb/types.pyt _serialize_sÑscCst|tƒr|j}n|S(N(RRR(RR((s5/tmp/pip-install-xdEqop/boto3/boto3/dynamodb/types.pyt _serialize_bÔs cCs g|D]}|j|ƒ^qS(N(R\(RRts((s5/tmp/pip-install-xdEqop/boto3/boto3/dynamodb/types.pyt _serialize_ssÙscCs g|D]}|j|ƒ^qS(N(R[(RRtn((s5/tmp/pip-install-xdEqop/boto3/boto3/dynamodb/types.pyt _serialize_nsÜscCs g|D]}|j|ƒ^qS(N(R](RRtb((s5/tmp/pip-install-xdEqop/boto3/boto3/dynamodb/types.pyt _serialize_bsßscCs g|D]}|j|ƒ^qS(N(R2(RRtv((s5/tmp/pip-install-xdEqop/boto3/boto3/dynamodb/types.pyt _serialize_lâscCs8tg|jƒD]!\}}||j|ƒf^qƒS(N(tdicttitemsR2(RRtkRd((s5/tmp/pip-install-xdEqop/boto3/boto3/dynamodb/types.pyt _serialize_mås(R)R*R+R2R-R4R5R7R9R;RPR=RARCRTRUR[R\R]R_RaRcReRi(((s5/tmp/pip-install-xdEqop/boto3/boto3/dynamodb/types.pyR,Gs, '                 tTypeDeserializercBsqeZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z RS( s7This class deserializes DynamoDB types to Python types.cCsz|stdƒ‚nt|jƒƒd}yt|d|jƒƒ}Wn!tk rktd|ƒ‚nX|||ƒS(síThe method to deserialize the DynamoDB data types. :param value: A DynamoDB value to be deserialized to a pythonic value. Here are the various conversions: DynamoDB Python -------- ------ {'NULL': True} None {'BOOL': True/False} True/False {'N': str(value)} Decimal(str(value)) {'S': string} string {'B': bytes} Binary(bytes) {'NS': [str(value)]} set([Decimal(str(value))]) {'SS': [string]} set([string]) {'BS': [bytes]} set([bytes]) {'L': list} list {'M': dict} dict :returns: The pythonic value of the DynamoDB type. sGValue must be a nonempty dictionary whose key is a valid dynamodb type.is_deserialize_%ss!Dynamodb type %s is not supported(RRStkeysR.R/tAttributeError(RRR0t deserializer((s5/tmp/pip-install-xdEqop/boto3/boto3/dynamodb/types.pyt deserializeës cCsdS(N(R3(RR((s5/tmp/pip-install-xdEqop/boto3/boto3/dynamodb/types.pyt_deserialize_null scCs|S(N((RR((s5/tmp/pip-install-xdEqop/boto3/boto3/dynamodb/types.pyt_deserialize_boolscCs tj|ƒS(N(RXRY(RR((s5/tmp/pip-install-xdEqop/boto3/boto3/dynamodb/types.pyt_deserialize_nscCs|S(N((RR((s5/tmp/pip-install-xdEqop/boto3/boto3/dynamodb/types.pyt_deserialize_sscCs t|ƒS(N(R(RR((s5/tmp/pip-install-xdEqop/boto3/boto3/dynamodb/types.pyt_deserialize_bscCstt|j|ƒƒS(N(tsetRQRq(RR((s5/tmp/pip-install-xdEqop/boto3/boto3/dynamodb/types.pyt_deserialize_nsscCstt|j|ƒƒS(N(RtRQRr(RR((s5/tmp/pip-install-xdEqop/boto3/boto3/dynamodb/types.pyt_deserialize_ssscCstt|j|ƒƒS(N(RtRQRs(RR((s5/tmp/pip-install-xdEqop/boto3/boto3/dynamodb/types.pyt_deserialize_bs"scCs g|D]}|j|ƒ^qS(N(Rn(RRRd((s5/tmp/pip-install-xdEqop/boto3/boto3/dynamodb/types.pyt_deserialize_l%scCs8tg|jƒD]!\}}||j|ƒf^qƒS(N(RfRgRn(RRRhRd((s5/tmp/pip-install-xdEqop/boto3/boto3/dynamodb/types.pyt_deserialize_m(s(R)R*R+RnRoRpRqRrRsRuRvRwRxRy(((s5/tmp/pip-install-xdEqop/boto3/boto3/dynamodb/types.pyRjés "         N(t collectionsRRtdecimalRRRRRRRtbotocore.compatR R:R8R<R?R>R@RR6RBRDRXRMRORtobjectRR,Rj(((s5/tmp/pip-install-xdEqop/boto3/boto3/dynamodb/types.pyt s("¢