ó »z]c @sddlmZmZmZddlmZmZmZmZddlm Z ddl m Z dZ dZ dZdZd Zd Zd Zd Zd ZdZedddddddeeeeegƒZee jfZdefd„ƒYZdefd„ƒYZdefd„ƒYZdS(iÿÿÿÿ(tDecimaltContexttClamped(tOverflowtInexactt UnderflowtRounded(tcollections_abc(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((s3/tmp/pip-build-kBFYxq/boto3/boto3/dynamodb/types.pyt__init__0s/cCs,t|tƒr|j|jkS|j|kS(N(RRR(Rtother((s3/tmp/pip-build-kBFYxq/boto3/boto3/dynamodb/types.pyt__eq__6scCs|j|ƒ S(N(R"(RR!((s3/tmp/pip-build-kBFYxq/boto3/boto3/dynamodb/types.pyt__ne__;scCs d|jS(Ns Binary(%r)(R(R((s3/tmp/pip-build-kBFYxq/boto3/boto3/dynamodb/types.pyt__repr__>scCs|jS(N(R(R((s3/tmp/pip-build-kBFYxq/boto3/boto3/dynamodb/types.pyt__str__AscCs t|jƒS(N(thashR(R((s3/tmp/pip-build-kBFYxq/boto3/boto3/dynamodb/types.pyt__hash__Ds( t__name__t __module__t__doc__R R"R#R$R%R'(((s3/tmp/pip-build-kBFYxq/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((s3/tmp/pip-build-kBFYxq/boto3/boto3/dynamodb/types.pyt serializeJscCs.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(RRR/tmsg((s3/tmp/pip-build-kBFYxq/boto3/boto3/dynamodb/types.pyR,js0           cCs|dkrtStS(N(R2tTruetFalse(RR((s3/tmp/pip-build-kBFYxq/boto3/boto3/dynamodb/types.pyR3‘s cCst|tƒrtStS(N(RtboolRFRG(RR((s3/tmp/pip-build-kBFYxq/boto3/boto3/dynamodb/types.pyR4–scCs>t|tjtfƒrtSt|tƒr:tdƒ‚ntS(Ns9Float types are not supported. Use Decimal types instead.(RRt integer_typesRRFtfloatRRG(RR((s3/tmp/pip-build-kBFYxq/boto3/boto3/dynamodb/types.pyR6›s  cCst|tjƒrtStS(N(RRt string_typesRFRG(RR((s3/tmp/pip-build-kBFYxq/boto3/boto3/dynamodb/types.pyR8£scCsIt|tƒrtSt|tƒr&tStjrEt|tjƒrEtStS(N(RRRFt bytearrayRtPY3t binary_typeRG(RR((s3/tmp/pip-build-kBFYxq/boto3/boto3/dynamodb/types.pyR:¨scCst|tjƒrtStS(N(RRtSetRFRG(RR((s3/tmp/pip-build-kBFYxq/boto3/boto3/dynamodb/types.pyt_is_set±scCs/|j|ƒr+tt||ƒkr+tSntS(N(RPRGtmapRF(RRttype_validator((s3/tmp/pip-build-kBFYxq/boto3/boto3/dynamodb/types.pyR<¶scCst|tjƒrtStS(N(RRtMappingRFRG(RR((s3/tmp/pip-build-kBFYxq/boto3/boto3/dynamodb/types.pyR@¼scCst|tƒrtStS(N(RtlistRFRG(RR((s3/tmp/pip-build-kBFYxq/boto3/boto3/dynamodb/types.pyRBÁscCstS(N(RF(RR((s3/tmp/pip-build-kBFYxq/boto3/boto3/dynamodb/types.pyt_serialize_nullÆscCs|S(N((RR((s3/tmp/pip-build-kBFYxq/boto3/boto3/dynamodb/types.pyt_serialize_boolÉscCs4ttj|ƒƒ}|dkr0tdƒ‚n|S(NtInfinitytNaNsInfinity and NaN not supported(RWRX(RtDYNAMODB_CONTEXTtcreate_decimalR(RRtnumber((s3/tmp/pip-build-kBFYxq/boto3/boto3/dynamodb/types.pyt _serialize_nÌs cCs|S(N((RR((s3/tmp/pip-build-kBFYxq/boto3/boto3/dynamodb/types.pyt _serialize_sÒscCst|tƒr|j}n|S(N(RRR(RR((s3/tmp/pip-build-kBFYxq/boto3/boto3/dynamodb/types.pyt _serialize_bÕs cCs g|D]}|j|ƒ^qS(N(R](RRts((s3/tmp/pip-build-kBFYxq/boto3/boto3/dynamodb/types.pyt _serialize_ssÚscCs g|D]}|j|ƒ^qS(N(R\(RRtn((s3/tmp/pip-build-kBFYxq/boto3/boto3/dynamodb/types.pyt _serialize_nsÝscCs g|D]}|j|ƒ^qS(N(R^(RRtb((s3/tmp/pip-build-kBFYxq/boto3/boto3/dynamodb/types.pyt _serialize_bsàscCs g|D]}|j|ƒ^qS(N(R1(RRtv((s3/tmp/pip-build-kBFYxq/boto3/boto3/dynamodb/types.pyt _serialize_lãscCs8tg|jƒD]!\}}||j|ƒf^qƒS(N(tdicttitemsR1(RRtkRe((s3/tmp/pip-build-kBFYxq/boto3/boto3/dynamodb/types.pyt _serialize_mæs(R(R)R*R1R,R3R4R6R8R:RPR<R@RBRURVR\R]R^R`RbRdRfRj(((s3/tmp/pip-build-kBFYxq/boto3/boto3/dynamodb/types.pyR+Hs, '                 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(RRTtkeysR-R.tAttributeError(RRR/t deserializer((s3/tmp/pip-build-kBFYxq/boto3/boto3/dynamodb/types.pyt deserializeìs cCsdS(N(R2(RR((s3/tmp/pip-build-kBFYxq/boto3/boto3/dynamodb/types.pyt_deserialize_nullscCs|S(N((RR((s3/tmp/pip-build-kBFYxq/boto3/boto3/dynamodb/types.pyt_deserialize_boolscCs tj|ƒS(N(RYRZ(RR((s3/tmp/pip-build-kBFYxq/boto3/boto3/dynamodb/types.pyt_deserialize_nscCs|S(N((RR((s3/tmp/pip-build-kBFYxq/boto3/boto3/dynamodb/types.pyt_deserialize_sscCs t|ƒS(N(R(RR((s3/tmp/pip-build-kBFYxq/boto3/boto3/dynamodb/types.pyt_deserialize_bscCstt|j|ƒƒS(N(tsetRQRr(RR((s3/tmp/pip-build-kBFYxq/boto3/boto3/dynamodb/types.pyt_deserialize_nsscCstt|j|ƒƒS(N(RuRQRs(RR((s3/tmp/pip-build-kBFYxq/boto3/boto3/dynamodb/types.pyt_deserialize_ss scCstt|j|ƒƒS(N(RuRQRt(RR((s3/tmp/pip-build-kBFYxq/boto3/boto3/dynamodb/types.pyt_deserialize_bs#scCs g|D]}|j|ƒ^qS(N(Ro(RRRe((s3/tmp/pip-build-kBFYxq/boto3/boto3/dynamodb/types.pyt_deserialize_l&scCs8tg|jƒD]!\}}||j|ƒf^qƒS(N(RgRhRo(RRRiRe((s3/tmp/pip-build-kBFYxq/boto3/boto3/dynamodb/types.pyt_deserialize_m)s(R(R)R*RoRpRqRrRsRtRvRwRxRyRz(((s3/tmp/pip-build-kBFYxq/boto3/boto3/dynamodb/types.pyRkês "         N(tdecimalRRRRRRRt boto3.compatRtbotocore.compatRR9R7R;R>R=R?RR5RARCRYRLRNRtobjectRR+Rk(((s3/tmp/pip-build-kBFYxq/boto3/boto3/dynamodb/types.pyt s("¢