
    %
i                        d Z ddlZeZ G d d          Zedk    rdaddZeZ	  e            Z e	e
                                            e	e                                            e	e
                    d                      e	e                    d	                      e	e                    d
                      e	e                                           eZdS # eZw xY w e            e_        dS )a}  Provides a class Stdin which can be used to emulate the regular old
sys.stdin for the PythonWin interactive window. Right now it just pops
up a input() dialog. With luck, someone will integrate it into the
actual PythonWin interactive window someday.

WARNING: Importing this file automatically replaces sys.stdin with an
instance of Stdin (below). This is useful because you can just open
Stdin.py in PythonWin and hit the import button to get it set up right
if you don't feel like changing PythonWin's source. To put things back
the way they were, simply use this magic incantation:
    import sys
    sys.stdin = sys.stdin.real_file
    Nc                   N    e Zd Zd Zd Zd ZddZddZd Zd fd	Z	d
 Z
d ZdS )Stdinc                 D    t           j        | _        d| _        d| _        d S )N F)sysstdin	real_filebufferclosedselfs    C:\Users\Dell Inspiron 16\Desktop\tws\AgrotaPowerBi\back-agrota-powerbi\mcp-client-agrota\venv\Lib\site-packages\pythonwin/pywin/framework/stdin.py__init__zStdin.__init__   s        c                 X    | j         t          |          t          | j         |          S )zBForward most functions to the real sys.stdin for absolute realism.)r	   AttributeErrorgetattr)r   names     r   __getattr__zStdin.__getattr__   s*    >! &&&t~t,,,r   c                     dS )zAReturn 1 if the file is connected to a tty(-like) device, else 0.    r   s    r   isattyzStdin.isatty%   s    qr   c                 V    |                      |          }|                     |          S )a  Read at most size bytes from the file (less if the read
        hits EOF or no more data is immediately available on a pipe,
        tty or similar device). If the size argument is negative or
        omitted, read all data until EOF is reached. The bytes are
        returned as a string object. An empty string is returned when
        EOF is encountered immediately. (For certain files, like ttys,
        it makes sense to continue reading after an EOF is hit.))_Stdin__get_lines_Stdin__extract_from_buffer)r   sizeresult_sizes      r   readz
Stdin.read)   s+     &&t,,))+666r   c                     |                      |d           }d| j        d|         v r(| j                            dd|          dz   }|dk    sJ n|}|                     |          S )a  Read one entire line from the file. A trailing newline
        character is kept in the string2.6 (but may be absent when a file ends
        with an incomplete line). If the size argument is present and
        non-negative, it is a maximum byte count (including the trailing
        newline) and an incomplete line may be returned. An empty string is
        returned when EOF is hit immediately. Note: unlike stdio's fgets(),
        the returned string contains null characters (' ') if they occurred
        in the input.
        c                 
    d| v S )N
r   r
   s    r   <lambda>z Stdin.readline.<locals>.<lambda>>   s
    DFN r   r#   Nr   r   )r   r
   findr   )r   r   maximum_result_sizer   s       r   readlinezStdin.readline4   s~     #..t5R5RSS4;3 33444+**44GHH1LK?????-K))+666r   c                 L    | j         d|         }| j         |d         | _         |S )zfRemove the first character_count characters from the internal buffer and
        return them.
        Nr$   )r   character_countresults      r   __extract_from_bufferzStdin.__extract_from_bufferH   s/     -o-.k/"2"23r   c                     dS )NFr   r$   s    r   r%   zStdin.<lambda>P   s    E r   c                 t    || j                   s|dk     st          | j                   |k     ro	 |                                  n+# t          t          f$ r t          | j                   }Y nw xY w || j                   s|dk     Wt          | j                   |k     o|dk     rt          | j                   S |S )a  Keep adding lines to our internal buffer until done_reading(self.buffer)
        is true or EOF has been reached or we have desired_size bytes in the buffer.
        If desired_size < 0, we are never satisfied until we reach EOF. If done_reading
        is not supplied, it is not consulted.

        If desired_size < 0, returns the length of the internal buffer. Otherwise,
        returns desired_size.
        r   )r
   len_Stdin__get_lineEOFErrorKeyboardInterrupt)r   desired_sizedone_readings      r   __get_lineszStdin.__get_linesP   s     ,t{++ 		01DK 0 0< ? ?0!!!!! 0 0 0  #4;//	0 ,t{++ 		01DK 0 0< ? ? !t{###s   A %A-,A-c                 f    t                      }t          d|           | j        |z   dz   | _        dS )z@Grab one line from get_input_line() and append it to the buffer.z>>>r#   N)get_input_lineprintr
   )r   lines     r   
__get_linezStdin.__get_linei   s4    eTkD(4/r   c                     g }d}|dk    s||d         k     rT|                                  }|dk    rn9|t          |          z  }|                    |           |dk    H||d         k     T|S )a3  Read until EOF using readline() and return a list containing the lines
        thus read. If the optional sizehint argument is present, instead of
        reading up to EOF, whole lines totalling approximately sizehint bytes
        (possibly after rounding up to an internal buffer size) are read.
        r   r   r   )r(   r/   append)r   sizehintr+   
total_readr9   s        r   	readlineszStdin.readlineso   s     
"nn
Xa[ 8 8==??Drzz#d))#JMM$ "nn
Xa[ 8 8 r   N)r   )__name__
__module____qualname__r   r   r   r    r(   r   r   r0   r?   r   r   r   r   r      s          
- - -  	7 	7 	7 	77 7 7 7(   6J5I        20 0 0    r   r   __main__a  this is some test
input that I am hoping
~
will be very instructive
and when I am done
I will have tested everything.
Twelve and twenty blackbirds
baked in a pie. Patty cake
patty cake so am I.
~
Thirty-five niggling idiots!
Sell you soul to the devil, baby
c                    dt           vrt          t                     }nt                               d          }t           d|         }t           |dz   d         a t          |          dk    s|d         dk    rt          |S )zfReplacement for input() which pulls lines out of global test_input.
        For testing only!
        r#   Nr   r   ~)
test_inputr/   r&   r1   )promptend_of_line_posr+   s      r   
fake_inputrI      s{    
 z!!!*ooOO(ood33O,_,-! 3 5 56
v;;!vayC//Nr      /      )N)__doc__r   inputr7   r   r@   rF   rI   xr8   r    r(   r?   r   r   r   r   <module>rP      sM    


d d d d d d d dN zJ     N	EGGaffhhajjllaffRjjajjnnajjmmakkmmCIIIs   B;C$ $C(