File: //usr/lib/python3/dist-packages/twisted/spread/__pycache__/banana.cpython-38.pyc
U
W[.0 � @ s6 d Z ddlmZmZ ddlZddlZddlmZ ddlm Z ddl
mZ ddlm
Z
ddlmZmZmZ dd lmZ G d
d� de�Zdd
� Zdd� Zed�Zed�Zed�Zed�Zed�Zed�Zed�Zed�Z ed�Z!dd� Z"da#e"d� dZ$G dd� de j%ej&�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
� )�absolute_import�divisionN)�BytesIO)�protocol)�styles)�log)� iterbytes�long� _bytesChr)�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 sJ | dkr|t d�� d S | dks(td��| rF|t | d@ �� | d? } q(d S )Nr z!can only encode positive integers� � )�chr�AssertionError)Zinteger�streamr r r �int2b128 s r c C s6 d}d}t | �D ] }t|�}||| 7 }|dK }q|S )a
Convert an integer represented as a base 128 string into an L{int} or
L{long}.
@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} or L{long}
� r r )r �ord)�st�e�i�char�nr r r �b1282int'