Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/twisted/protocols/__pycache__/basic.cpython-39.pyc
Ðазад
a k�h�{ � @ sd d Z ddlZddlZddlmZ ddlmZmZmZ ddl m Z ddlmZm Z mZ ddlmZ dd � Zd e_ dZG dd� de�ZG d d� de�ZG dd� dej�ZG dd� dej�ZG dd� d�ZG dd� deje�ZG dd� de�ZG dd� d�ZG dd� deje�ZG dd� de�Z G dd � d e�Z!G d!d"� d"e�Z"G d#d$� d$�Z#e e j$�G d%d&� d&��Z%dS )'zN Basic protocols, such as line-oriented, netstring, and int prefixed strings. � N)�BytesIO)�calcsize�pack�unpack)�implementer)�defer� interfaces�protocol)�logc C s d� tt| ���d�d| dg�S )N� �ascii� :� ,)�join�str�len�encode)�data� r ��/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/twisted/protocols/basic.py�_formatNetstring s r z_ Convert some C{bytes} into netstring format. @param data: C{bytes} that will be reformatted. c @ s e Zd ZdZdS )�NetstringParseErrorz= The incoming data is not in valid Netstring format. N��__name__� __module__�__qualname__�__doc__r r r r r ) s r c @ s e Zd ZdZdS )�IncompleteNetstringz2 Not enough data to complete a netstring. Nr r r r r r / s r c @ s� e Zd ZdZdZe�d�Ze�d�ZdZ dZ dZdZe d �\ZZd d� Zdd � Zdd� Zdd� Zdd� Zdd� Zdd� Zdd� Zdd� Zdd� Zdd� Zd d!� Zd"d#� Zd$d%� Zd&d'� Zd(d)� Zd*d+� Z d,d-� Z!d.S )/�NetstringReceiveraM A protocol that sends and receives netstrings. See U{http://cr.yp.to/proto/netstrings.txt} for the specification of netstrings. Every netstring starts with digits that specify the length of the data. This length specification is separated from the data by a colon. The data is terminated with a comma. Override L{stringReceived} to handle received netstrings. This method is called with the netstring payload as a single argument whenever a complete netstring is received. Security features: 1. Messages are limited in size, useful if you don't want someone sending you a 500MB netstring (change C{self.MAX_LENGTH} to the maximum length you wish to accept). 2. The connection is lost if an illegal message is received. @ivar MAX_LENGTH: Defines the maximum length of netstrings that can be received. @type MAX_LENGTH: C{int} @ivar _LENGTH: A pattern describing all strings that contain a netstring length specification. Examples for length specifications are C{b'0:'}, C{b'12:'}, and C{b'179:'}. C{b'007:'} is not a valid length specification, since leading zeros are not allowed. @type _LENGTH: C{re.Match} @ivar _LENGTH_PREFIX: A pattern describing all strings that contain the first part of a netstring length specification (without the trailing comma). Examples are '0', '12', and '179'. '007' does not start a netstring length specification, since leading zeros are not allowed. @type _LENGTH_PREFIX: C{re.Match} @ivar _PARSING_LENGTH: Indicates that the C{NetstringReceiver} is in the state of parsing the length portion of a netstring. @type _PARSING_LENGTH: C{int} @ivar _PARSING_PAYLOAD: Indicates that the C{NetstringReceiver} is in the state of parsing the payload portion (data and trailing comma) of a netstring. @type _PARSING_PAYLOAD: C{int} @ivar brokenPeer: Indicates if the connection is still functional @type brokenPeer: C{int} @ivar _state: Indicates if the protocol is consuming the length portion (C{PARSING_LENGTH}) or the payload (C{PARSING_PAYLOAD}) of a netstring @type _state: C{int} @ivar _remainingData: Holds the chunk of data that has not yet been consumed @type _remainingData: C{string} @ivar _payload: Holds the payload portion of a netstring including the trailing comma @type _payload: C{BytesIO} @ivar _expectedPayloadSize: Holds the payload size plus one for the trailing comma. @type _expectedPayloadSize: C{int} 韆 s (0|[1-9]\d*)(:)s (0|[1-9]\d*)$zBThe received netstring does not start with a length specification.zpThe length specification of the received netstring cannot be represented in Python - it causes an OverflowError!zQThe received netstring is longer than the maximum %s specified by self.MAX_LENGTHz4The received netstring is not terminated by a comma.� c C s: t j�| |� d| _d| _t� | _| j| _d| _ d| _ dS )z+ Initializes the protocol. r r N)r �Protocol�makeConnection�_remainingData�_currentPayloadSizer �_payload�_PARSING_LENGTH�_state�_expectedPayloadSize� brokenPeer)�self� transportr r r r"