Your IP : 216.73.216.213


Current Path : /opt/alt/python37/lib64/python3.7/site-packages/twisted/conch/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/site-packages/twisted/conch/__pycache__/recvline.cpython-37.pyc

B

:��]-�@s�dZddlZddlmZddlmZmZddlmZm	Z	ddl
mZiZGdd�de
�Zeej�Gd	d
�d
e
��ZGdd�de
�ZGd
d�dej�ZGdd�de�ZdS)z4
Basic line editing support.

@author: Jp Calderone
�N)�implementer)�insults�helper)�log�reflect)�	iterbytescs@eZdZdZdd�Z�fdd�Z�fdd�Z�fdd	�Z�ZS)
�Loggingz�
    Wrapper which logs attribute lookups.

    This was useful in debugging something, I guess.  I forget what.
    It can probably be deleted or moved somewhere more appropriate.
    Nothing special going on here, really.
    cCsF||_t�|j�}t�|d�}|dt|<t|dt|�d�|_dS)Nr��-�w)	�originalrZqual�	__class__�	_counters�get�open�str�_logFile)�selfr�key�count�r�I/opt/alt/python37/lib64/python3.7/site-packages/twisted/conch/recvline.py�__init__s
zLogging.__init__csttt|��d��S)Nr)r�superr�__getattribute__)r)r
rr�__str__%szLogging.__str__csttt|��d��S)Nr)�reprrrr)r)r
rr�__repr__)szLogging.__repr__cs8tt|��d�}tt|��d�}|�|d�t||�S)Nrr�
)rrr�write�getattr)r�namerZlogFile)r
rrr-szLogging.__getattribute__)	�__name__�
__module__�__qualname__�__doc__rrrr�
__classcell__rr)r
rrs
rc@sheZdZdZx&dD]ZedZe�d�Zee�qWdZ	dZ
dd�Zxej
D]Zed	eef�qLWd
S)�TransportSequencea_
    An L{ITerminalTransport} implementation which forwards calls to
    one or more other L{ITerminalTransport}s.

    This is a cheap way for servers to keep track of the state they
    expect the client to see, since all terminal manipulations can be
    send to the real client and to a terminal emulator that lives in
    the server process.
    )sUP_ARROWs
DOWN_ARROWsRIGHT_ARROWs
LEFT_ARROWsHOMEsINSERTsDELETEsENDsPGUPsPGDNsF1sF2sF3sF4sF5sF6sF7sF8sF9sF10sF11sF12s = object()�ascii�	�cGs|std��||_dS)Nz7Cannot construct a TransportSequence with no transports)�AssertionError�
transports)rr,rrrrLszTransportSequence.__init__zldef %s(self, *a, **kw):
    for tpt in self.transports:
        result = tpt.%s(*a, **kw)
    return result
N)r"r#r$r%�keyIDZ	execBytes�decodeZexecStr�exec�TAB�	BACKSPACErr�ITerminalTransport�methodrrrrr'5s


r'cs(eZdZdZ�fdd�Zdd�Z�ZS)�LocalTerminalBufferMixina�
    A mixin for RecvLine subclasses which records the state of the terminal.

    This is accomplished by performing all L{ITerminalTransport} operations on both
    the transport passed to makeConnection and an instance of helper.TerminalBuffer.

    @ivar terminalCopy: A L{helper.TerminalBuffer} instance which efforts
    will be made to keep up to date with the actual terminal
    associated with this protocol instance.
    cs,t��|_|j��tt|��t||j��S)N)rZTerminalBuffer�terminalCopy�connectionMaderr4�makeConnectionr')rZ	transport)r
rrr7gs


z'LocalTerminalBufferMixin.makeConnectioncCs
t|j�S)N)rr5)rrrrrnsz LocalTerminalBufferMixin.__str__)r"r#r$r%r7rr&rr)r
rr4[s
r4c@s�eZdZdZdZdZdZdZdZe	j
�d�Zdd	�Z
d
d�Zdd
�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Z d0S)1�RecvLinea�
    L{TerminalProtocol} which adds line editing features.

    Clients will be prompted for lines of input with all the usual
    features: character echoing, left and right arrow support for
    moving the cursor to different areas of the line buffer, backspace
    and delete for removing characters, and insert for toggling
    between typeover and insert mode.  Tabs will be expanded to enough
    spaces to move the cursor to the next tabstop (every four
    characters by default).  Enter causes the line buffer to be
    cleared and the line to be passed to the lineReceived() method
    which, by default, does nothing.  Subclasses are responsible for
    redrawing the input prompt (this will probably change).
    �P��)s>>> s... rr(cCspg|_d|_|j}|j|j|j|j|j|jd|j	d|j	|j
|j|j|j
|j|j|j|j|j|ji
|_|��dS)Nr�
�
)�
lineBuffer�lineBufferIndex�terminalZ
LEFT_ARROW�handle_LEFTZRIGHT_ARROW�handle_RIGHTr0�
handle_TAB�
handle_RETURNr1�handle_BACKSPACEZDELETE�
handle_DELETEZINSERT�
handle_INSERT�HOME�handle_HOMEZEND�
handle_END�keyHandlers�initializeScreen)r�trrrr6�szRecvLine.connectionMadecCs*|j��|j�|j|j�|��dS)N)r@�resetr�ps�pn�
setInsertMode)rrrrrL�s

zRecvLine.initializeScreencCs(d�|j�}|d|j�||jd�fS)N�)�joinr>r?)r�srrr�currentLineBuffer�szRecvLine.currentLineBuffercCsd|_|j�tjjg�dS)N�insert)�moder@ZsetModesr�modes�IRM)rrrrrQ�szRecvLine.setInsertModecCsd|_|j�tjjg�dS)N�typeover)rWr@Z
resetModesrrXrY)rrrr�setTypeoverMode�szRecvLine.setTypeoverModecCs$|j�|j|jd�|j��dS)z�
        Write a line containing the current input prompt and the current line
        buffer at the current cursor position.
        rRN)r@rrOrPrSr>)rrrr�
drawInputLine�szRecvLine.drawInputLinecCs,|j��|j��||_||_|��dS)N)r@ZeraseDisplayZ
cursorHome�width�heightr\)rr]r^rrr�terminalSize�s


zRecvLine.terminalSizecCsdS)Nr)r�seqrrr�unhandledControlSequence�sz!RecvLine.unhandledControlSequencecCsH|j�|�}|dk	r|�n(||jkr4|�|d�nt�d|f�dS)NFzReceived unhandled keyID: %r)rKr�_printableChars�characterReceivedr�msg)rr-�modifier�mrrr�keystrokeReceived�s
zRecvLine.keystrokeReceivedcCsR|jdkr|j�|j|�n|g|j|j|jd�<|jd7_|j�|�dS)NrVr	)rWr>rVr?r@r)r�chZmoreCharactersComingrrrrc�s

zRecvLine.characterReceivedcCsH|jt|j�|j}|j�|�|j|7_|j�td|��dS)N� )�TABSTOP�lenr>r@�
cursorForwardr?�extendr)r�nrrrrC�szRecvLine.handle_TABcCs&|jdkr"|jd8_|j��dS)Nrr	)r?r@�cursorBackward)rrrrrA�s
zRecvLine.handle_LEFTcCs,|jt|j�kr(|jd7_|j��dS)Nr	)r?rkr>r@rl)rrrrrB�szRecvLine.handle_RIGHTcCs|jr|j�|j�d|_dS)Nr)r?r@ro)rrrrrIszRecvLine.handle_HOMEcCs0t|j�|j}|r,|j�|�t|j�|_dS)N)rkr>r?r@rl)r�offsetrrrrJ
szRecvLine.handle_ENDcCs:|jdkr6|jd8_|j|j=|j��|j��dS)Nrr	)r?r>r@ro�deleteCharacter)rrrrrEs



zRecvLine.handle_BACKSPACEcCs(|jt|j�kr$|j|j=|j��dS)N)r?rkr>r@rq)rrrrrFs
zRecvLine.handle_DELETEcCs0d�|j�}g|_d|_|j��|�|�dS)NrRr)rSr>r?r@ZnextLine�lineReceived)r�linerrrrDs

zRecvLine.handle_RETURNcCs.|jdkst�|jdkr"|��n|��dS)N)rZrVrZ)rWr+rQr[)rrrrrG's

zRecvLine.handle_INSERTcCsdS)Nr)rrsrrrrr/szRecvLine.lineReceivedN)!r"r#r$r%r]r^rjrOrP�string�	printable�encoderbr6rLrUrQr[r\r_rargrcrCrArBrIrJrErFrDrGrrrrrrr8ss6

	r8c@s@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)�HistoricRecvLinea;
    L{TerminalProtocol} which adds both basic line-editing features and input history.

    Everything supported by L{RecvLine} is also supported by this class.  In addition, the
    up and down arrows traverse the input history.  Each received line is automatically
    added to the end of the input history.
    cCs<t�|�g|_d|_|j}|j�|j|j|j	|j
i�dS)Nr)r8r6�historyLines�historyPositionr@rK�updateZUP_ARROW�	handle_UPZ
DOWN_ARROW�handle_DOWN)rrMrrrr6<s
zHistoricRecvLine.connectionMadecCs&t|j�}|d|j�||jd�fS)N)�tuplerxry)r�brrr�currentHistoryBufferGs
z%HistoricRecvLine.currentHistoryBuffercCsB|r>x$t|dd��D]}|�|d�qW|�|dd�d�dS)N���TF)rrc)r�bufrhrrr�_deliverBufferLszHistoricRecvLine._deliverBuffercCsp|jr*|jt|j�kr*|j�d�|j��|jdkrl|��|j��|jd8_g|_|�	|j|j�dS)NrRrr	)
r>ryrkrx�appendrSrIr@�eraseToLineEndr�)rrrrr{Ss

zHistoricRecvLine.handle_UPcCs||jt|j�dkrN|��|j��|jd7_g|_|�|j|j�n*|��|j��t|j�|_g|_d|_dS)Nr	r)	ryrkrxrIr@r�r>r�r?)rrrrr|`s

zHistoricRecvLine.handle_DOWNcCs0|jr|j�d�|j��t|j�|_t�|�S)NrR)r>rxr�rSrkryr8rD)rrrrrDrszHistoricRecvLine.handle_RETURNN)
r"r#r$r%r6rr�r{r|rDrrrrrw4s
rw)r%rtZzope.interfacerZtwisted.conch.insultsrrZtwisted.pythonrrZtwisted.python.compatrr�objectrr2r'r4ZTerminalProtocolr8rwrrrr�<module>	s %B