\e[c@sdZddlZddlZddlZejddkraeZeZe Z e Z dZ n!eZeefZeZ dZ eedrddlmZydd lmZWn!ek rdd lmZnXeZd efd YZneZdd lmZdZddlmZmZm Z m!Z!m"Z"m#Z#ddl$m%Z%dZ&dZ'dZ(dZ)dZ*dZ+dZ,dZ-dZ.dZ/dZ0e1e2dZ3dZ4dZ5dZ6defdYZ7defdYZ8dS(s.Fallback pure Python implementation of msgpackiNiicCs |jS(N(titems(td((s;/tmp/pip-install-0xiv62/pip/pip/_vendor/msgpack/fallback.pytdict_iteritems scCs |jS(N(t iteritems(R((s;/tmp/pip-install-0xiv62/pip/pip/_vendor/msgpack/fallback.pyRstpypy_version_info(t newlist_hint(t BytesBuilder(t StringBuildertStringIOcBs&eZddZdZdZRS(tcCs>|r.tt||_|jj|n t|_dS(N(Rtlentbuildertappend(tselfts((s;/tmp/pip-install-0xiv62/pip/pip/_vendor/msgpack/fallback.pyt__init__ scCsPt|tr|j}nt|tr<t|}n|jj|dS(N(t isinstancet memoryviewttobytest bytearraytbytesR R (R R((s;/tmp/pip-install-0xiv62/pip/pip/_vendor/msgpack/fallback.pytwrite&s cCs |jjS(N(R tbuild(R ((s;/tmp/pip-install-0xiv62/pip/pip/_vendor/msgpack/fallback.pytgetvalue,s(t__name__t __module__RRR(((s;/tmp/pip-install-0xiv62/pip/pip/_vendor/msgpack/fallback.pyRs  (tBytesIOcCsgS(N((tsize((s;/tmp/pip-install-0xiv62/pip/pip/_vendor/msgpack/fallback.pyt1s(t BufferFullt OutOfDatatUnpackValueErrortPackValueErrortPackOverflowErrort ExtraData(tExtTypeiiiiicCs6|||kr"|||kS|||kSdS(N((tobjttttypettuple((s;/tmp/pip-install-0xiv62/pip/pip/_vendor/msgpack/fallback.pyt_check_type_strictNscCs~yt|}WnItk r[tsUtt|}tjdt|tq\nX|jdkrzt dn|S(Nsusing old buffer interface to unpack %s; this leads to unpacking errors if slicing is used and will be removed in a future versionis$cannot unpack from multi-byte object( Rt TypeErrortPY3tbuffertwarningstwarnR&tRuntimeWarningtitemsizet ValueError(R$tview((s;/tmp/pip-install-0xiv62/pip/pip/_vendor/msgpack/fallback.pyt_get_data_from_bufferUs    cKs)tjdt|j}t||S(NsbDirect calling implementation's unpack() is deprecated, Use msgpack.unpack() or unpackb() instead.(R,R-tPendingDeprecationWarningtreadtunpackb(tstreamtkwargstdata((s;/tmp/pip-install-0xiv62/pip/pip/_vendor/msgpack/fallback.pytunpackgs  cKsttd|}|j|y|j}Wntk rKtdnX|jrpt||jn|S(s Unpack an object from `packed`. Raises `ExtraData` when `packed` contains extra bytes. See :class:`Unpacker` for options. sData is not enough.N( tUnpackertNonetfeedt_unpackRRt_got_extradataR"t_get_extradata(tpackedR7tunpackertret((s;/tmp/pip-install-0xiv62/pip/pip/_vendor/msgpack/fallback.pyR5os   R:cBseZdZddeeddddddeddddddZdZdZdZ dZ dZ d Z d Z ed Zed Zd ZdZeZddZddZddZddZdZRS(sB Streaming unpacker. arguments: :param file_like: File-like object having `.read(n)` method. If specified, unpacker reads serialized data from it and :meth:`feed()` is not usable. :param int read_size: Used as `file_like.read(read_size)`. (default: `min(16*1024, max_buffer_size)`) :param bool use_list: If true, unpack msgpack array to Python list. Otherwise, unpack to Python tuple. (default: True) :param bool raw: If true, unpack msgpack raw to Python bytes (default). Otherwise, unpack to Python str (or unicode on Python 2) by decoding with UTF-8 encoding (recommended). Currently, the default is true, but it will be changed to false in near future. So you must specify it explicitly for keeping backward compatibility. *encoding* option which is deprecated overrides this option. :param callable object_hook: When specified, it should be callable. Unpacker calls it with a dict argument after unpacking msgpack map. (See also simplejson) :param callable object_pairs_hook: When specified, it should be callable. Unpacker calls it with a list of key-value pairs after unpacking msgpack map. (See also simplejson) :param str encoding: Encoding used for decoding msgpack raw. If it is None (default), msgpack raw is deserialized to Python bytes. :param str unicode_errors: (deprecated) Used for decoding msgpack raw with *encoding*. (default: `'strict'`) :param int max_buffer_size: Limits size of data waiting unpacked. 0 means system's INT_MAX (default). Raises `BufferFull` exception when it is insufficient. You should set this parameter when unpacking data from untrusted source. :param int max_str_len: Limits max length of str. (default: 2**31-1) :param int max_bin_len: Limits max length of bin. (default: 2**31-1) :param int max_array_len: Limits max length of array. (default: 2**31-1) :param int max_map_len: Limits max length of map. (default: 2**31-1) example of streaming deserialize from file-like object:: unpacker = Unpacker(file_like, raw=False) for o in unpacker: process(o) example of streaming deserialize from socket:: unpacker = Unpacker(raw=False) while True: buf = sock.recv(1024**2) if not buf: break unpacker.feed(buf) for o in unpacker: process(o) iicCsT|dk rtjdtn| dkr4d} n|dkrLt|_n0t|jsjtdn||_ t |_t |_ t jdkrt|j |_n |j |_d|_d|_| pd|_||jkrtd n|p t|jd|_t||_||_| |_||_||_||_||_| |_| |_ | |_!||_"||_#||_$d|_%|dk rt| rtd n|dk rt| rtdn|dk rt| rtdn|dk r5|dk r5tdnt| sPtdndS(Ns.encoding is deprecated, Use raw=False instead.tstricts!`file_like.read` must be callableiiiiiis.read_size must be smaller than max_buffer_sizeiis`list_hook` is not callables`object_hook` is not callables#`object_pairs_hook` is not callables8object_pairs_hook and object_hook are mutually exclusives`ext_hook` is not callable(iiiIii@(&R;R,R-R3tTruet_feedingtcallableR4R)t file_liketFalseRt_buffertsyst version_infoR+t _buffer_viewt_buff_it_buf_checkpointt_max_buffer_sizeR0tmint _read_sizetboolt_rawt _encodingt_unicode_errorst _use_listt _list_hookt _object_hookt_object_pairs_hookt _ext_hookt _max_str_lent _max_bin_lent_max_array_lent _max_map_lent _max_ext_lent_stream_offset(R RGt read_sizetuse_listtrawt object_hooktobject_pairs_hookt list_hooktencodingtunicode_errorstmax_buffer_sizetext_hookt max_str_lent max_bin_lent max_array_lent max_map_lent max_ext_len((s;/tmp/pip-install-0xiv62/pip/pip/_vendor/msgpack/fallback.pyRs\                         cCs|jstt|}t|j|jt||jkrMtn|jdkr|j|j4|j|j8_d|_n|j|7_dS(Ni( REtAssertionErrorR2R RIRMRORRN(R t next_bytesR1((s;/tmp/pip-install-0xiv62/pip/pip/_vendor/msgpack/fallback.pyR<s )   cCs)|j|j|j7_|j|_dS(s+ Gets rid of the used parts of the buffer. N(R`RMRN(R ((s;/tmp/pip-install-0xiv62/pip/pip/_vendor/msgpack/fallback.pyt_consume,scCs|jt|jkS(N(RMR RI(R ((s;/tmp/pip-install-0xiv62/pip/pip/_vendor/msgpack/fallback.pyR>1scCs|j|jS(N(RIRM(R ((s;/tmp/pip-install-0xiv62/pip/pip/_vendor/msgpack/fallback.pyR?4scCs |j|S(N(t_read(R tn((s;/tmp/pip-install-0xiv62/pip/pip/_vendor/msgpack/fallback.pyt read_bytes7scCs5|j||j}|||_|j|||!S(N(t_reserveRMRI(R Rtti((s;/tmp/pip-install-0xiv62/pip/pip/_vendor/msgpack/fallback.pyRs:s   cCs0t|j|j|}|dkr*dS|jrH|j|_tn|jdkr|j|j4|j|j8_d|_n| }xr|dkrt|j|}|jj |}|sPnt |t st |j|7_|t|8}qWt|j||jkr,d|_tndS(Ni( R RIRMRERNRtmaxRQRGR4RRRp(R Rtt remain_bytest to_read_bytest read_data((s;/tmp/pip-install-0xiv62/pip/pip/_vendor/msgpack/fallback.pyRvAs,       cCs t}d}d}|jd|j|j}|jd7_|d@dkrW|}n/ |d@dkrxd|dA}n |d@dkr|d@}t}||jkrtd ||jn|j|}n |d @d kr|d @}t }||j kr td ||j q nk |d @dkre|d @}t }||j kr td||j q n! |dkrzd}n |dkrt }n |dkrt}n |dkrt}|jd|j|j}|jd7_||jkr td||jfn|j|}ng |dkrt}|jdtjd|j|jd}|jd7_||jkrtd||jfn|j|}n |dkr3t}|jdtjd|j|jd}|jd7_||jkr!td||jfn|j|}nS |dkrt}|jdtjd|j|j\}}|jd7_||jkrtd||jfn|j|}n |dkrKt}|jdtjd|j|j\}}|jd7_||jkr9td||jfn|j|}n; |d krt}|jd!tjd"|j|j\}}|jd!7_||jkrtd||jfn|j|}n|d#kr!|jdtjd$|j|jd}|jd7_ne|d%krk|jd&tjd'|j|jd}|jd&7_n|d(kr|jd|j|j}|jd7_n|d)kr|jdtjd|j|jd}|jd7_n|d*kr:|jdtjd|j|jd}|jd7_nL|d+kr|jd&tjd,|j|jd}|jd&7_n|d-kr|jdtjd.|j|jd}|jd7_n|d/kr|jdtjd0|j|jd}|jd7_nn|d1krb|jdtjd2|j|jd}|jd7_n$|d3kr|jd&tjd4|j|jd}|jd&7_n|d5kr)t}|jdkrtdd|jfn|jdtjd6|j|j\}}|jd7_n]|d7krt}|jdkrftdd|jfn|jdtjd8|j|j\}}|jd7_n|d9kr# t}|jdkrtdd|jfn|jd!tjd:|j|j\}}|jd!7_nc|d;kr t}|jd&kr` tdd&|jfn|jd<tjd=|j|j\}}|jd<7_n|d>kr t}|jd?kr tdd?|jfn|jd@tjdA|j|j\}}|jd@7_ni|dBkr t}|jd|j|j}|jd7_||jkr td ||jn|j|}n|dCkr t}|jdtjd|j|j\}|jd7_||jkr td ||jn|j|}nm|dDkr t}|jdtjd|j|j\}|jd7_||jkr td ||jn|j|}n|dEkr t }|jdtjd|j|j\}|jd7_||j kr td ||j q nr|dFkr t }|jdtjd|j|j\}|jd7_||j kr td ||j q n|dGkr |jdtjd|j|j\}|jd7_||j kr td||j nt }n|dHkrv |jdtjd|j|j\}|jd7_||j krm td||j nt }ntdI||||fS(JNiiiiiiiis%s exceeds max_str_len(%s)iiis%s exceeds max_array_len(%s)s%s exceeds max_map_len(%s)iiiis%s exceeds max_bin_len(%s)iis>Hiis>IitBbs%s exceeds max_ext_len(%s)iis>Hbiis>Ibis>fiis>diiiis>Qitbis>his>iis>qitb1sitb2sitb4sii tb8siiitb16siiiiiiisUnknown header: 0x%x(tTYPE_IMMEDIATER;RvRIRMtTYPE_RAWR[RRst TYPE_ARRAYR]tTYPE_MAPR^RHRDtTYPE_BINR\tstructt unpack_fromRLtTYPE_EXTR_(R texecutettypRtR$R}tL((s;/tmp/pip-install-0xiv62/pip/pip/_vendor/msgpack/fallback.pyt _read_headeras                   !  !  !                      !  !  !  !  !                c sj|\}}}|tkrC|tkr?tdn|S|tkrn|tkrjtdn|S|tkr|tkrx!t|D]}jtqWdSt |}x*t|D]}|j jt qWj dk rj |}njr|St|S|tkr|tkrlx.t|D] }jtjtqDWdSjdk rjfdt|D}n`i}x6t|D](}jt }jt ||Wstutf_8(RtEX_READ_ARRAY_HEADERRRtEX_READ_MAP_HEADERRtEX_SKIPtxrangeR=RR RRWR;RVR'RYRXRRTtdecodeRURSRRRZRRRp( R RRRtR$RwRBRtkey((R s;/tmp/pip-install-0xiv62/pip/pip/_vendor/msgpack/fallback.pyR=5sh                 cCs|S(N((R ((s;/tmp/pip-install-0xiv62/pip/pip/_vendor/msgpack/fallback.pyt__iter__sscCsIy!|jt}|j|SWn!tk rD|jtnXdS(N(R=RRrRt StopIteration(R RB((s;/tmp/pip-install-0xiv62/pip/pip/_vendor/msgpack/fallback.pyt__next__vs   cCsT|jt|dk rFtjdt||j|j|j!n|j dS(Ns;`write_bytes` option is deprecated. Use `.tell()` instead.( R=RR;R,R-tDeprecationWarningRIRNRMRr(R t write_bytes((s;/tmp/pip-install-0xiv62/pip/pip/_vendor/msgpack/fallback.pytskips   cCsV|jt}|dk rHtjdt||j|j|j!n|j |S(Ns;`write_bytes` option is deprecated. Use `.tell()` instead.( R=RR;R,R-RRIRNRMRr(R RRB((s;/tmp/pip-install-0xiv62/pip/pip/_vendor/msgpack/fallback.pyR9s   cCsV|jt}|dk rHtjdt||j|j|j!n|j |S(Ns;`write_bytes` option is deprecated. Use `.tell()` instead.( R=RR;R,R-RRIRNRMRr(R RRB((s;/tmp/pip-install-0xiv62/pip/pip/_vendor/msgpack/fallback.pytread_array_headers   cCsV|jt}|dk rHtjdt||j|j|j!n|j |S(Ns;`write_bytes` option is deprecated. Use `.tell()` instead.( R=RR;R,R-RRIRNRMRr(R RRB((s;/tmp/pip-install-0xiv62/pip/pip/_vendor/msgpack/fallback.pytread_map_headers   cCs|jS(N(R`(R ((s;/tmp/pip-install-0xiv62/pip/pip/_vendor/msgpack/fallback.pyttellsN(RRt__doc__R;RDR#RR<RrR>R?RuRsRvRRR=RRtnextRR9RRR(((s;/tmp/pip-install-0xiv62/pip/pip/_vendor/msgpack/fallback.pyR:s6N    E       >      tPackercBseZdZdddeeeedZeee dZ dZ dZ dZ dZdZdZd Zed Zd Zd Zd ZdZRS(sh MessagePack Packer usage: packer = Packer() astream.write(packer.pack(a)) astream.write(packer.pack(b)) Packer's constructor has some keyword arguments: :param callable default: Convert user type to builtin type that Packer supports. See also simplejson's document. :param bool use_single_float: Use single precision float type for float. (default: False) :param bool autoreset: Reset buffer after each pack and return its content as `bytes`. (default: True). If set this to false, use `bytes()` to get content and `.reset()` to clear buffer. :param bool use_bin_type: Use bin type introduced in msgpack spec 2.0 for bytes. It also enables str8 type for unicode. :param bool strict_types: If set to true, types will be checked to be exact. Derived classes from serializeable types will not be serialized and will be treated as unsupported type and forwarded to default. Additionally tuples will not be serialized as lists. This is useful when trying to implement accurate serialization for python types. :param str encoding: (deprecated) Convert unicode to bytes with this encoding. (default: 'utf-8') :param str unicode_errors: Error handler for encoding unicode. (default: 'strict') cCs|dkrd}ntjdt|dkr:d}n||_||_||_||_||_||_ t |_ |dk rt |st dqn||_dS(NRs.encoding is deprecated, Use raw=False instead.RCsdefault must be callable(R;R,R-R3t _strict_typest _use_floatt _autoresett _use_bin_typeRTRURRIRFR)t_default(R tdefaultRgRhtuse_single_floatt autoresett use_bin_typet strict_types((s;/tmp/pip-install-0xiv62/pip/pip/_vendor/msgpack/fallback.pyRs$             c CsKt}|jr|}t}n ttf}xtrF|dkrNtdn|dkrj|jjdS||t r|r|jjdS|jjdS||t r6d|kodknr|jjt j d|Sd|kodknr|jjt j d |Sd|ko5d knrY|jjt j d d |Sd |kopdknr|jjt j dd|Sd |kodknr|jjt j dd|Sd|kod knr |jjt j dd|Sd|ko!dknrE|jjt j dd|Sd|ko\dknr|jjt j dd|Sd|kodknr|jjt j dd|Sd|kodknr|jjt j d d!|S| r'|j dk r'|j |}t}q-ntd"n||ttfrt|}|d;krtd%t|jn|j||jj|S||tr%|jdkrtd&n|j|j|j}t|}|d<krtd'n|j||jj|S||trt||j}|d=krbtd(n|j||jj|S||tr|jr|jjt j d)d*|S|jjt j d+d,|S||trr|j }|j!} t"|t#s t$t"| ts t$t| } | d-krK|jjd.n| d#krj|jjd/n| d0kr|jjd1n| d2kr|jjd3n| d4kr|jjd5n{| d kr|jjt j d6d7| nM| dkr#|jjt j dd8| n|jjt j dd9| |jjt j d ||jj| dS|||rt|}|j%|x,t&|D]} |j'|| |d-qWdS||t(r|j)t|t*||d-S| r0|j dk r0|j |}d-}q-ntd:|fq-WdS(>Nisrecursion limit exceededsssitBiR}itBBiis>Bbiis>BHiis>BhiIs>BIiis>Biils>BQiIs>BqisInteger value out of rangeii s%s is too larges5Can't encode unicode string: no encoding is specifiedsString is too largesMemoryview is too larges>Bfis>Bdiissisisiss>BBiiisCannot serialize %rIII(+RHRtlistR'RDR R;RIRRRt int_typesRtpackRR!RRR R&Rt_pack_bin_headertUnicodeRTR)tencodeRUt_pack_raw_headerRR/tfloatRR#tcodeR8RtintRpt_pack_array_headerRt_packtdictt_pack_map_pairsR( R R$t nest_limittchecktcheck_type_strictt default_usedt list_typesRtRR8RRw((s;/tmp/pip-install-0xiv62/pip/pip/_vendor/msgpack/fallback.pyRs                         " "   cCsmy|j|Wnt|_nX|jj}|jrQt|_ntrit||_n|S(N(RRRIRRtUSING_STRINGBUILDER(R R$RB((s;/tmp/pip-install-0xiv62/pip/pip/_vendor/msgpack/fallback.pyRTs  cCsY|jt|||jj}|jr=t|_ntrUt||_n|S(N(RR RIRRRR(R tpairsRB((s;/tmp/pip-install-0xiv62/pip/pip/_vendor/msgpack/fallback.pytpack_map_pairsas cCse|dkrtn|j||jj}|jrIt|_ntrat||_n|S(Nii I(R RRIRRRR(R RtRB((s;/tmp/pip-install-0xiv62/pip/pip/_vendor/msgpack/fallback.pytpack_array_headerjs    cCse|dkrtn|j||jj}|jrIt|_ntrat||_n|S(Nii I(R t_pack_map_headerRIRRRR(R RtRB((s;/tmp/pip-install-0xiv62/pip/pip/_vendor/msgpack/fallback.pytpack_map_headerus    cCst|tstdnd|ko5dknsItdnt|tsgtdnt|}|dkrtdn|dkr|jjd n|d kr|jjd n|d kr|jjd n|dkr |jjdn|dkr)|jjdn~|dkrX|jjdt j d|nO|dkr|jjdt j d|n |jjdt j d||jjt j d||jj|dS(Nstypecode must have int type.iistypecode should be 0-127sdata must have bytes typeIsToo large dataisisisisisisRiss>Hss>I( RRR)R0RR R RIRRR(R ttypecodeR8R((s;/tmp/pip-install-0xiv62/pip/pip/_vendor/msgpack/fallback.pyt pack_ext_types4        # # cCs|dkr,|jjtjdd|S|dkrW|jjtjdd|S|dkr|jjtjdd |Std dS( NiRiis>BHiIs>BIisArray is too large(RIRRRR (R Rt((s;/tmp/pip-install-0xiv62/pip/pip/_vendor/msgpack/fallback.pyRs    cCs|dkr,|jjtjdd|S|dkrW|jjtjdd|S|dkr|jjtjdd |Std dS( NiRiis>BHiIs>BIisDict is too large(RIRRRR (R Rt((s;/tmp/pip-install-0xiv62/pip/pip/_vendor/msgpack/fallback.pyRs    cCsP|j|x<|D]4\}}|j||d|j||dqWdS(Ni(RR(R RtRRtktv((s;/tmp/pip-install-0xiv62/pip/pip/_vendor/msgpack/fallback.pyRs cCs|dkr/|jjtjdd|n|jrf|dkrf|jjtjdd|nh|dkr|jjtjdd |n:|d kr|jjtjd d |n td dS(NiRiis>BBiis>BHiIs>BIisRaw is too large(RIRRRRR (R Rt((s;/tmp/pip-install-0xiv62/pip/pip/_vendor/msgpack/fallback.pyRs #" " "cCs|js|j|S|dkrA|jjtjdd|S|dkrl|jjtjdd|S|dkr|jjtjdd |Std dS( Nis>BBiis>BHiIs>BIisBin is too large(RRRIRRRR (R Rt((s;/tmp/pip-install-0xiv62/pip/pip/_vendor/msgpack/fallback.pyRs     cCs |jjS(N(RIR(R ((s;/tmp/pip-install-0xiv62/pip/pip/_vendor/msgpack/fallback.pyRscCst|_dS(N(RRI(R ((s;/tmp/pip-install-0xiv62/pip/pip/_vendor/msgpack/fallback.pytresetsN(RRRR;RHRDRtDEFAULT_RECURSE_LIMITRR(RRRRRRRRRRRRR(((s;/tmp/pip-install-0xiv62/pip/pip/_vendor/msgpack/fallback.pyRs$(   m   (9RRJRR,RKRDR*RRtstrRtrangeRRRHtlongtunicodethasattrt__pypy__Rt__pypy__.buildersRRt ImportErrorRtobjectRtioRtpip._vendor.msgpack.exceptionsRRRR R!R"tpip._vendor.msgpackR#RRRRRRRRRRRR&R'R(R2R9R5R:R(((s;/tmp/pip-install-0xiv62/pip/pip/_vendor/msgpack/fallback.pytsZ        .   %