U
    oufÄ	  ã                   @  sn   d dl mZ d dlZd dlZd dlmZmZ ddlmZm	Z	m
Z
 ddgZdd	d
ddœdd„Zddœdd„ZdS )é    )ÚannotationsN)ÚContextManagerÚTextIOé   )Ú
DummyInputÚInputÚ	PipeInputÚcreate_inputÚcreate_pipe_inputFzTextIO | NoneÚboolr   )ÚstdinÚalways_prefer_ttyÚreturnc                 C  s¶   t jdkr<ddlm} | dkr.t jdkr.tƒ S || p8t jƒS ddlm} | dkr€t j} |r€t jt jt j	fD ]}| 
¡ rj|}  q€qjz|  ¡  W n tjk
r¨   tƒ  Y S X || ƒS dS )a§  
    Create the appropriate `Input` object for the current os/environment.

    :param always_prefer_tty: When set, if `sys.stdin` is connected to a Unix
        `pipe`, check whether `sys.stdout` or `sys.stderr` are connected to a
        pseudo terminal. If so, open the tty for reading instead of reading for
        `sys.stdin`. (We can open `stdout` or `stderr` for reading, this is how
        a `$PAGER` works.)
    Úwin32r   )Ú
Win32InputN)Ú
Vt100Input)ÚsysÚplatformr   r   r   r   Zvt100r   ÚstdoutÚstderrÚisattyÚfilenoÚioÚUnsupportedOperation)r   r   r   r   Úobj© r   úA/tmp/pip-unpacked-wheel-8milen2s/prompt_toolkit/input/defaults.pyr	      s$    

zContextManager[PipeInput])r   c                  C  s6   t jdkrddlm}  |  ¡ S ddlm} | ¡ S dS )aA  
    Create an input pipe.
    This is mostly useful for unit testing.

    Usage::

        with create_pipe_input() as input:
            input.send_text('inputdata')

    Breaking change: In prompt_toolkit 3.0.28 and earlier, this was returning
    the `PipeInput` directly, rather than through a context manager.
    r   r   )ÚWin32PipeInput)ÚPosixPipeInputN)r   r   Z
win32_piper   ÚcreateZ
posix_piper   )r   r   r   r   r   r
   ;   s
    
)NF)Ú
__future__r   r   r   Útypingr   r   Úbaser   r   r   Ú__all__r	   r
   r   r   r   r   Ú<module>   s   þ,