�
��e6 � �^ � d dl Z ddlmZmZ G d� de� Z G d� de� Z G d� d e� Zy)
� N� )�EOF�TIMEOUTc �D � e Zd Zd
d�Zd� Zd� Zd� Zdd�Zdd�Zd� Z d
d �Z
y)�Expecterc � � || _ || _ |dk( r|j }|| _ d | _ t |d� r|j
| _ y y )N����longest_string)�spawn�searcher�searchwindowsize�lookback�hasattrr
)�selfr r r
s �0/usr/lib/python3/dist-packages/pexpect/expect.py�__init__zExpecter.__init__ sR � ���
� ��
� �r�!�$�5�5�� 0�����
��8�-�.�$�3�3�D�M� /� c � � | j }| j }|t |� kD rt |� }|j ||| j � }|dk\ r�|j � |_ |j j ||j d � |j j � dt |� |j z
|_ |j � |_ |j j ||j d � ||j |j |_
|j |_ ||_ |S | j s| j rm| j xs | j }|j j# � |kD r5|j � |_ |j j || d � y y y �Nr )r r �len�searchr
�buffer_type�_buffer�write�end�_before�getvalue�start�before�after�match�match_indexr �tell)r �window�freshlenr r �index�maintains r � do_searchzExpecter.do_search sk � ��
�
���=�=���c�&�k�!��6�{�H������$�2G�2G�H���A�:�!�-�-�/�E�M��M�M����x�|�|�}� 5�6� �=�=�1�1�3��C��K�(�.�.�0�1�3�E�L�!�-�-�/�E�M��M�M����x�|�|�}� 5�6� �������=�E�K�"�.�.�E�K� %�E���L�
�
"�
"�d�m�m��,�,�=��
�
�H��}�}�!�!�#�h�.� %� 1� 1� 3��
��
�
�#�#�F�H�9�:�$6�7� /� '4r c � � | j }|j j � }|j j � }|}||kD �r1| j sL|j � |_ |j j
� }|j j |� �nL|| j k r}|j � |_ |j j t d|| j z
� � |j j � }|j j |� n�|j j t d|| j z
� � |j j � }ns| j rM|j j t d|| j z
� � |j j � }n|j j
� }| j ||� S r )r r r# r r
r r r �seek�max�readr( )r r �
before_len�buf_lenr% r$ s r �
existing_datazExpecter.existing_data* s} � � �
�
���]�]�'�'�)�
��-�-�$�$�&��������(�(� %� 1� 1� 3��
����/�/�1���
�
�#�#�F�+��4�0�0�0� %� 1� 1� 3��
��
�
�"�"���:��(=�(=�=�>�@����+�+�-���
�
�#�#�F�+��
�
�"�"�3�q�'�D�4I�4I�*I�#J�K����+�+�-���$�$��
�
�"�"�3�q�'�D�4I�4I�*I�#J�K����+�+�-�����/�/�1���~�~�f�h�/�/r c � � | j }t |� }|j j |� | j s�| j
r�|j j � }|j j |� |j j t d|| j
z
� � |j j � }�n+|j j |� |j }�nt |� | j k\ s|j j � sO|| j d }|j � |_ |j j || j d � n�|j j |� |j j � }|j j t d|| j z
� � |j j � }| j ||� S r )r r r r r
r r r# r* r+ r, �bufferr r( )r �datar r% �old_lenr$ �new_lens r �new_datazExpecter.new_dataH s� � ��
�
���t�9��
�
�
���D�!��$�$��}�}��-�-�,�,�.���
�
�#�#�D�)��
�
�"�"�3�q�'�D�M�M�*A�#B�C����+�+�-�� �
�
�#�#�D�)������4�y�D�1�1�1����9K�9K�9M��t�4�4�4�5�6�� %� 1� 1� 3��
��
�
�#�#�F�D�,A�,A�+A�+B�$C�D��
�
�#�#�D�)��-�-�,�,�.���
�
�"�"�3�q�'�D�4I�4I�*I�#J�K����+�+�-���~�~�f�h�/�/r Nc �� � | j }|j j � |_ |j � |_ |j � |_ t |_ | j j }|dk\ rt |_
||_ |S d |_
d |_ t |� }|d| j z z
}|�t |� dz |z }t
|� }d |_
|��Nr z
searcher: %s�
)r r r r r r r r r � eof_indexr! r" |