HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/dockerpty/__pycache__/tty.cpython-310.pyc
o

�7U��@sPddlmZddlZddlZddlZddlZddlZdd�ZGdd�de�Z	dS)�)�absolute_importNc	Csdt�|���s	dSzt�dt�|tjd��}W|Sztj	dtj	df}WY|SYYdS)z�
    Return a tuple (rows,cols) representing the size of the TTY `fd`.

    The provided file descriptor should be the stdout stream of the TTY.

    If the TTY size cannot be determined, returns None.
    N�hh�hhhh�LINES�COLUMNS)
�os�isatty�fileno�struct�unpack�fcntl�ioctl�termios�
TIOCGWINSZ�environ)�fd�dims�r�//usr/lib/python3/dist-packages/dockerpty/tty.py�sizes	��rc@sJeZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�Terminalz�
    Terminal provides wrapper functionality to temporarily make the tty raw.

    This is useful when streaming data from a pseudo-terminal into the tty.

    Example:

        with Terminal(sys.stdin, raw=True):
            do_things_in_raw_mode()
    TcCs||_||_d|_dS)a
        Initialize a terminal for the tty with stdin attached to `fd`.

        Initializing the Terminal has no immediate side effects. The `start()`
        method must be invoked, or `with raw_terminal:` used before the
        terminal is affected.
        N)r�raw�original_attributes)�selfrrrrr�__init__=s	
zTerminal.__init__cCs|��|S)z?
        Invoked when a `with` block is first entered.
        )�start�rrrr�	__enter__KszTerminal.__enter__cGs|��dS)z:
        Invoked when a `with` block is finished.
        N)�stop)r�_rrr�__exit__TszTerminal.__exit__cCs|jS)zE
        Returns True if the TTY should operate in raw mode.
        )rrrrr�israw\szTerminal.israwcCs>t�|j���r|��rt�|j�|_t�	|j�dSdSdS)z}
        Saves the current terminal attributes and makes the tty raw.

        This method returns None immediately.
        N)
rrrr	r!r�	tcgetattrr�tty�setrawrrrrrds�zTerminal.startcCs&|jdurt�|jtj|j�dSdS)z�
        Restores the terminal attributes back to before setting raw mode.

        If the raw terminal was not started, does nothing.
        N)rr�	tcsetattrr�	TCSADRAINrrrrrps
��z
Terminal.stopcCsdjt|�j|j|jd�S)Nz{cls}({fd}, raw={raw}))�clsrr)�format�type�__name__rrrrrr�__repr__~s
�zTerminal.__repr__N)T)r*�
__module__�__qualname__�__doc__rrr r!rrr+rrrrr1s
	r)
�
__future__rrrr#rr
r�objectrrrrr�<module>s