+
    Df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;;;;;
ug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 3a 7$$ UQY/!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	 "% GG@ NN113,,,'', GGC NN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    NNbE!HOOD!''-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MV\        8X  dE   \        V4      pV\        8  d   \        R4      h\        V	4      V8  d   WR 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       MV\"        8X  d   T	p\        V4      pV! V) 4       MV\$        8X  d   T	p\        V4      ) pV! V4       MV\&        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$NN	,,f;;&( *C*J*JT[[!V+ ( !KC'%Ag (
 )))%K++-.  #,CC!G,H')$D3x$***!O'')*  4sm#%&KLL  #r+V#sm#%&MNNt9#!$ZFD#J'SsmW$smW$smS}nU"sm..s3&&%/DM-0MdX.VWWU"t9>!"XFFMM$R9!<=),>xl*KLL)Yr]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-    #yy)@)@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   cD%=))3x*$!"G3s8+"UVVSXu%$KT) S!!***c4H4H.H!"ASF"JKK&&&#u%gq#u%c
((($c
$gU##%L&++dC()U##""e+7K7K0K//4)es8j(%>#c(L  S5)fc
5<<&tCy13 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BE#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+    9LBLNN3  ""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HHB"
	!Q4K 	!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   