File: //lib/python3/dist-packages/twisted/spread/__pycache__/banana.cpython-310.pyc
o
�b�/ � @ s� d Z ddlZddlZddlmZ ddlmZ ddlmZ ddl m
Z
ddlmZ ddl
mZ G d d
� d
e�Zdd� Zd
d� ZdZdZdZdZdZdZdZdZdZdd� Zdaed� dZG dd� dejej �Z!e!� Z"e"�#� e"�$d� dd� Z%d d!� Z&dS )"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 @ s e Zd ZdS )�BananaErrorN)�__name__�
__module__�__qualname__� r r �7/usr/lib/python3/dist-packages/twisted/spread/banana.pyr s r c C sN | dkr
|d� d S | dksJ d��| r%|t | d@ f�� | d? } | sd S d S )Nr � z!can only encode positive integers� � )�bytes)�integer�streamr r r
�int2b128 s �r c C s6 d}d}t | �D ]}t|�}||| 7 }|dK }q|S )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 r )r �ord)�st�e�i�char�nr r r
�b1282int) s
r � �� �� �� �� �� �� �� �c C s | a dS )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)�limitr r r
�setPrefixLimitK s
r'