+
    üÐj’/  ã                   ób  € R t ^ RIt^ RIt^ RIHt ^ RIHt ^ RIHt ^ RI	H
t
 ^ RIHt ^ RIHt  ! R R	]4      tR
 tR tRtRtRtRtRtRtRtRtRtR tRs]! ^@4       Rt ! R R]P>                  ]P@                  4      t!]!! 4       t"]"PG                  4        ]"PI                  R4       R t%R t&R# )zé
Banana -- s-exp based protocol.

Future Plans: This module is almost entirely stable.  The same caveat applies
to it as applies to L{twisted.spread.jelly}, however.  Read its future plans
for more details.

@author: Glyph Lefkowitz
N)ÚBytesIO)Úprotocol)Ústyles)Úlog)Ú	iterbytes)ÚfullyQualifiedNamec                   ó   € ] tR t^tRtR# )ÚBananaError© N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__static_attributes__r
   ó    Ú7/usr/lib/python3/dist-packages/twisted/spread/banana.pyr	   r	      s   † Ûr   r	   c                 óœ   € V ^ 8X  d   V! R4       R# V ^ 8”  g   Q R4       hV '       d%   V! \        V ^,          34      4       V ^,	          p K,  R# )é    ó    Nz!can only encode positive integers)Úbytes)ÚintegerÚstreams   &&r   Úint2b128r      sJ   € Ø�!„|ÙˆuŒÙØ�QŒ;Ð;Ð;Ó;ˆ;ß
ÙŒu�g •nÐ&Ó'Ô(Ø˜Q•,Šñ r   c                óx   € ^p^ p\        V 4       F&  p\        V4      pW$V,          ,          pV^,          pK(  	  V# )zÕ
Convert an integer represented as a base 128 string into an L{int}.

@param st: The integer encoded in a byte string.
@type st: L{bytes}

@return: The integer value extracted from the byte string.
@rtype: L{int}
)r   Úord)ÚstÚeÚiÚcharÚns   &    r   Úb1282intr    )   s@   € ð 	
€AØ	€AÜ˜"–ˆÜ�‹IˆØ	��U�
ˆØ	ˆa�Šñ ð €Hr   ó   €ó   �ó   ‚ó   ƒó   „ó   …ó   †ó   ‡c                ó
   € V s R# )aK  
Set the limit on the prefix length for all Banana connections
established after this call.

The prefix length limit determines how many bytes of prefix a banana
decoder will allow before rejecting a potential object as too large.

@type limit: L{int}
@param limit: The number of bytes of prefix for banana to allow when
decoding.
N)Ú_PREFIX_LIMIT)Úlimits   &r   ÚsetPrefixLimitr,   K   s	   € ð ‚Mr   c                   óf  a € ] tR t^at o RtRR.tRt]tR t	R t
R tR tR	 tR
 tRtR tR t/ R^bR^bR^bR^bR^bR^bR^bR^bR^	bR^
bR^bR^bR^bR^bR^bR^bR^bR^R ^R!^R"^R#^R$^R%^R&^R'^R(^R)^R*^R+^R,^/Ct/ t]P)                  4        F  w  tt]]]&   K  	  R1R- ltR. tR/ tR0tV tR# )2ÚBananazÑ
L{Banana} implements the I{Banana} s-expression protocol, client and
server.

@ivar knownDialects: These are the profiles supported by this Banana
    implementation.
@type knownDialects: L{list} of L{bytes}
ó   pbó   noneNc                ó    € Wn         ^V^,          ,          ) ^,           V n        RV n        RV n        ^V^,          ,          ^,
          V n        R# )z\
Set the prefix limit for decoding done by this protocol instance.

@see: L{setPrefixLimit}
Ni   €iÿÿÿ)ÚprefixLimitÚ_smallestLongIntÚ_smallestIntÚ_largestIntÚ_largestLongInt)Úselfr+   s   &&r   r,   ÚBanana.setPrefixLimitr   sI   € ð !ÔØ"#¨°­	Õ"2Ð 3°aÕ 7ˆÔØ$ˆÔØ$ˆÔØ  U¨Q¥YÕ/°!Õ3ˆÖr   c                ó   € R# )z@Surrogate for connectionMade
Called after protocol negotiation.
Nr
   ©r7   s   &r   ÚconnectionReadyÚBanana.connectionReady~   s   ‚ r   c                ó2   € Wn         V P                  4        R # ©N)ÚcurrentDialectr;   )r7   Údialects   &&r   Ú_selectDialectÚBanana._selectDialectƒ   s   € Ø%ÔØ×ÑÖr   c                óú  € V P                   '       d   V P                  V4       R# V P                  '       dq   V F8  pW P                  9   g   K  V P	                  V4       V P                  V4        R# 	  \        P                  ! R 4       V P                  P                  4        R# WP                  9   d   V P                  V4       R# \        P                  ! R4       V P                  P                  4        R# )zSThe client doesn't speak any of the protocols offered by the server: disconnecting.zYThe client selected a protocol the server didn't suggest and doesn't know: disconnecting.N)
r?   ÚexpressionReceivedÚisClientÚknownDialectsÚsendEncodedrA   r   ÚmsgÚ	transportÚloseConnection)r7   ÚobjÚ	serverVers   && r   ÚcallExpressionReceivedÚBanana.callExpressionReceived‡   sÂ   € Ø××ÐØ×#Ñ# CÖ(ð �}�}ˆ}ã!$�IØ ×$6Ñ$6Ö6Ø×(Ñ(¨Ô3Ø×+Ñ+¨IÔ6Úñ	 "%ô —G’Gð@ôð —N‘N×1Ñ1Ö3à×,Ñ,Ô,Ø×'Ñ'¨Ö,ô —G’GðCôð —N‘N×1Ñ1Ö3r   c                óœ   € V P                  \        4       R V n        V P                  '       g   V P	                  V P
                  4       R # R # r>   )r,   r*   r?   rE   rG   rF   r:   s   &r   ÚconnectionMadeÚBanana.connectionMade¥   s:   € Ø×ÑœMÔ*Ø"ˆÔØ�}�}ˆ}Ø×Ñ˜T×/Ñ/Ö0ñ r   c                ó’   € V P                   pV'       d"   VR,          ^,          P                  V4       R# V P                  V4       R# )é   Néÿÿÿÿ)Ú	listStackÚappendrM   )r7   ÚitemÚls   && r   ÚgotItemÚBanana.gotItem«   s0   € Ø�N‰NˆßØˆb�E�!�H�O‰O˜DÖ!à×'Ñ'¨Ö-r   r   c                ó¸  € V P                   V,           pV P                  pV P                  pV'       Ed   V P                   V8w  g4   Q R P                  \	        V P                   4      \	        V4      4      4       hW n         ^ p\        V4       F  pV\        8¼  d    M<V^,           pK  	  WPP                  8”  d   \        RV P                  3,          4      hR# VRV pW%V^,            pW%^,           R p	\        V4      V P                  8”  d   \        RV P                  3,          4      hV\        8X  d9   \        V4      pV\        8”  d   \        R4      hVP                  V. 34       T	pEM‹V\        8X  dE   \        V4      pV\        8”  d   \        R4      h\        V	4      V8¼  d   W—R pV! V	RV 4       EM>R# V\        8X  d   T	p\        V4      pV! V4       EMV\         8X  d   T	p\        V4      pV! V4       MùV\"        8X  d   T	p\        V4      pV! V) 4       M×V\$        8X  d   T	p\        V4      ) pV! V4       MµV\&        8X  dJ   T	p\        V4      pV P(                  V,          p
V P*                  R8X  d
   V! V
4       Mp\-        RV
: 24      hV\.        8X  dH   \        V	4      ^8¼  d6   V	R,          pV! \0        P2                  ! R	V	R
,          4      ^ ,          4       MR# \-        RV: 24      hV'       g   EK×  \        VR,          ^,          4      VR,          ^ ,          8X  g   EK  VP5                  4       ^,          p
V! V
4       K[  RV n         R# )zThis ain't right: {} {}z1Security precaution: more than %d bytes of prefixNz9Security precaution: longer than %d bytes worth of prefixz#Security precaution: List too long.z%Security precaution: String too long.r/   zInvalid item for pb protocol :é   NNú!d:Nr\   NzInvalid Type Byte r   rT   )ÚbufferrU   rY   ÚformatÚreprr   ÚHIGH_BIT_SETr2   r	   ÚlenÚLISTr    Ú
SIZE_LIMITrV   ÚSTRINGÚINTÚLONGINTÚLONGNEGÚNEGÚVOCABÚincomingVocabularyr?   ÚNotImplementedErrorÚFLOATÚstructÚunpackÚpop)r7   Úchunkr^   rU   rY   ÚposÚchÚnumÚtypebyteÚrestrW   s   &&         r   ÚdataReceivedÚBanana.dataReceived´   sú  € Ø—‘˜uÕ$ˆØ—N‘Nˆ	Ø—,‘,ˆßˆfØ—;‘; &Ô(ð Ð*C×*JÑ*JÜ�T—[‘[Ó!Ü�V“ó+ó Ð(ð !ŒKØˆCÜ Ö'�ØœÔ%ÙØ˜A•g’ñ (ð
 ×)Ñ)Ô)Ü%ØKØ×+Ñ+Ð-õ.óð ñ Ø˜˜#�,ˆCØ C¨!¥GÐ,ˆHØ �'˜)Ð$ˆDÜ�3‹x˜$×*Ñ*Ô*Ü!ØOØ×'Ñ'Ð)õ*óð ð œ4ÔÜ˜s“m�ØœÔ#Ü%Ð&KÓLÐLØ× Ñ  # r Ô+Ø’ØœVÔ#Ü˜s“m�ØœÔ#Ü%Ð&MÓNÐNÜ�t“9 Ô#Ø! $˜Z�FÙ˜D  #˜JÖ'áØœS”Ø�Ü˜s“m�Ù˜–ØœWÔ$Ø�Ü˜s“m�Ù˜•ØœWÔ$Ø�Ü˜s“m�Ù˜˜•ØœS”Ø�Ü “}�n�Ù˜•ØœUÔ"Ø�Ü˜s“m�Ø×.Ñ.¨sÕ3�Ø×&Ñ&¨%Ô/á˜D•Mä-Ð0MÈdÉXÐ.VÓWÐWØœUÔ"Ü�t“9 ”>Ø! "�X�FÙœFŸMšM¨$°°RµÓ9¸!Õ<Õ=áä)Ð,>¸x¹lÐ*KÓLÐLß’)¤ Y¨r¥]°1Õ%5Ó!6¸)ÀB½-ÈÕ:J×!JØ —}‘}“ qÕ)�Ù˜–ØˆŽr   c                ó   € \        4       h)z=Called when an expression (list, string, or int) is received.)rl   )r7   Úlsts   &&r   rD   ÚBanana.expressionReceived  s   € ä!Ó#Ð#r   s   Nones   classs   dereferences	   references
   dictionarys   functions   instances   lists   modules
   persistents   tuples   unpersistables   copys   caches   cacheds   remotes   locals   lcaches   versions   logins   passwords	   challenges	   logged_ins   not_logged_ins   cachemessages   messages   answers   errors   decrefs   decaches   uncachec                óx   € . V n         \        P                  ! V P                  4      V n        ^ V n        Wn        R# )r   N)rU   ÚcopyÚoutgoingVocabularyÚoutgoingSymbolsÚoutgoingSymbolCountrE   )r7   rE   s   &&r   Ú__init__ÚBanana.__init__4  s-   € ØˆŒÜ#Ÿyšy¨×)@Ñ)@ÓAˆÔØ#$ˆÔ Ø Žr   c                ó¦   € \        4       pV P                  WP                  4       VP                  4       pV P                  P                  V4       R# )zÜ
Send the encoded representation of the given object:

@param obj: An object to encode and send.

@raise BananaError: If the given object is not an instance of one of
    the types supported by Banana.

@return: L{None}
N)r   Ú_encodeÚwriteÚgetvaluerI   )r7   rK   ÚencodeStreamÚvalues   &&  r   rG   ÚBanana.sendEncoded:  s=   € ô “yˆØ�‰�S×,Ñ,Ô-Ø×%Ñ%Ó'ˆØ�‰×Ñ˜UÖ#r   c           	     ó  € \        V\        \        34      '       dn   \        V4      \        8”  d   \        R \        V4      3,          4      h\        \        V4      V4       V! \        4       V F  pV P                  W24       K  	  R# \        V\        4      '       dÃ   WP                  8  g   WP                  8”  d   \        RV3,          4      hWP                  8  d   \        V) V4       V! \        4       R# V^ 8  d   \        V) V4       V! \        4       R# WP                  8:  d   \        W4       V! \         4       R# \        W4       V! \"        4       R# \        V\$        4      '       d,   V! \&        4       V! \(        P*                  ! RV4      4       R# \        V\,        4      '       d©   V P.                  R8X  d=   WP0                  9   d-   V P0                  V,          p\        WB4       V! \2        4       R# \        V4      \        8”  d   \        R\        V4      3,          4      h\        \        V4      V4       V! \4        4       V! V4       R# \        RP7                  \9        \;        V4      4      V4      4      h)z#list/tuple is too long to send (%d)zint is too large to send (%d)r]   r/   z$byte string is too long to send (%d)z#Banana cannot send {} objects: {!r}N)Ú
isinstanceÚlistÚtuplerb   rd   r	   r   rc   r„   Úintr3   r6   r4   rh   ri   r5   rf   rg   Úfloatrm   rn   Úpackr   r?   r   rj   re   r_   r   Útype)r7   rK   r…   ÚelemÚsymbolIDs   &&&  r   r„   ÚBanana._encodeJ  sÕ  € Ü�cœD¤%˜=×)Ò)Ü�3‹xœ*Ô$Ü!Ð"GÌ3ÈsË8È+Õ"UÓVÐVÜ”S˜“X˜uÔ%Ù”$ŒKÛ�Ø—‘˜TÖ)ó ä˜œS×!Ò!Ø×*Ñ*Ô*¨c×4HÑ4HÔ.HÜ!Ð"AÀSÀFÕ"JÓKÐKØ×&Ñ&Ô&Ü˜#˜˜uÔ%Ù”g–Ø�q”Ü˜#˜˜uÔ%Ù”c–
Ø×(Ñ(Ô(Ü˜Ô$Ù”c–
ä˜Ô$Ù”g–Ü˜œU×#Ò#Ù”%ŒLÙ”&—+’+˜d CÓ(Ö)Ü˜œU×#Ò#à×"Ñ" eÔ+°×7KÑ7KÔ0KØ×/Ñ/°Õ4�Ü˜Ô)Ù”e–ä�s“8œjÔ(Ü%Ø>Ä#ÀcÃ(ÀÕLóð ô œ˜S› 5Ô)Ù”f”Ù�c–
äØ5×<Ñ<Ü&¤t¨C£yÓ1°3óóð r   )r5   r6   r4   r3   r^   r?   rE   rU   r€   r   r2   )rS   )r   r   r   r   Ú__doc__rF   r2   rd   Ú	sizeLimitr,   r;   rA   rM   rP   rY   r^   rw   rD   r~   rk   ÚitemsÚkÚvr�   rG   r„   r   Ú__classdictcell__)Ú__classdict__s   @r   r.   r.   a   s°  ø‡ € ñð ˜GÐ$€Mà€KØ€Iò
4òò
ò4ò<1ò.ð €FòQòf$ð#à�ð#ð 	�!ð#ð 	˜ð	#ð
 	�að#ð 	�qð#ð 	�Qð#ð 	�Qð#ð 	�ð#ð 	�1ð#ð 	�rð#ð 	�"ð#ð 	˜"ð#ð 	�ð#ð  	�"ð!#ð" 	�2ð##ð$ 	�2ð%#ð& 	�"ð'#ð( 	�2à�BØ�"Ø�RØ�bØ�bØ˜"Ø˜Ø�BØ�2Ø�"Ø�2Ø�BØ�BñE#ÐðJ ÐØ"×(Ñ(Ö*‰ˆˆ1Ø !Ð˜1Óñ +ô!ò$÷ -ð -r   r.   r0   c                óv   € \        4       pV\        n        \        P                  V 4       VP	                  4       # )zEncode a list s-expression.)r   Ú_irI   rG   r†   )rz   r‡   s   & r   Úencoderž   €  s+   € ä“9€LØ„B„LÜ‡N�N�3ÔØ× Ñ Ó"Ð"r   c                ó¼   € . pVP                   \        n         \        P                  V 4       R\        n        \        =V^ ,          #   R\        n        \        =i ; i)z!
Decode a banana-encoded string.
r   )rV   r�   rD   rw   r^   )r   rX   s   & r   Údecoder    ˆ  sM   € ð 	€AØŸH™H„BÔð"Ü
�‰˜ÔàŒŒ	ÜÐ!ØˆQ�4€Køð ŒŒ	ÜÑ!ús   ™A ÁAi  
 )'r•   r}   rn   Úior   Útwisted.internetr   Útwisted.persistedr   Útwisted.pythonr   Útwisted.python.compatr   Útwisted.python.reflectr   Ú	Exceptionr	   r   r    rc   rf   re   ri   rm   rg   rh   rj   ra   r,   r*   rd   ÚProtocolÚ	Ephemeralr.   r�   rP   rA   rž   r    r
   r   r   Ú<module>rª      sÌ   ðñ
ó Û Ý å %Ý $Ý Ý +Ý 5ô	�)ô 	òòð( €Ø€Ø	€Ø€Ø€à
€Ø
€à€à€òð  €Ù ˆrÔ à€
ôVˆX×Ñ × 0Ñ 0ô Vñt ƒX€Ø × Ñ Ô Ø × Ñ �'Ô ò#ôr   