%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/share/hplip/base/__pycache__/
Upload File :
Create Path :
Current File : //usr/share/hplip/base/__pycache__/tui.cpython-312.pyc

�

=	f*7����ddlZddlZddl�ddlmZddlmZddlmZdd�Z	dd�Z
dd	�Zd
�Zd�Z
dd�Zd
�Zd�Zd d�Zdd�Zd�ZGd�de�ZGd�de�ZdZdZdZdefd�Zdefd�Zd�Zd!d�Zd�Zy)"�N�)�*)�utils)�PY3)�inputc�d�t|�td�k(r
|dk(rd}nd}|�|r|dz
}n|dz
}n||z
}		ttj|��j	�j�}|sd|fS|dk(ry|dk(ry	|d
vrd|fStjd��k#t$rY�wwxYw)N��yTFz (y=yes*, n=no, q=quit) ? z (y=yes, n=no*, q=quit) ? �n)TF)TT)�q�cz/Please press <enter> or enter 'y', 'n', or 'q'.)�typer�log�bold�lower�strip�EOFError�error)�question�
default_value�
choice_prompt�
user_inputs    �/usr/share/hplip/base/tui.py�enter_yes_nor!s����M��d�2�h�&��C�� �M�!�M�����4�4�H��4�4�H��M�!��
�	��s�x�x��1�2�8�8�:�@�@�B�J����&�&�����������#��-�'�'��	�	�C�D�%���	��	�s�:B#�#	B/�.B/c�v�		ttj|��j�j	�}|s|�d|fS|dk(rd|fS	t
|�}||ks||kDrtjd||fz��~d|fS#t
$rY��wxYw#t$rtjd||fz�Y��wxYw)NTrFz8Please enter a number between %d and %d, or "q" to quit.)	rrrrrr�int�
ValueErrorr)r�	min_value�	max_valuerr�	value_ints      r�enter_ranger!Gs���
�	��s�x�x��1�2�8�8�:�@�@�B�J���(��]�*�*�����-�'�'�	��J��I��y� �I�	�$9��I�I�P��I�&�'�
(���Y����-�	��	���	��I�I�P��I�&�'�
(��	�s#�:B�B�	B�B�#B8�7B8c
��d|vr|jd�		ttj|��j	�j�}|s|s||k(r
|dk(rd|fSd|fS|dk(rd|fS||vrd|fStjddj|D�cgc]}d|z��	c}��d|�d����#t$rY��wxYwcc}w)	NrTFz
Please enter z, z'%s'z& or press <enter> for the default of 'z'.)	�appendrrrrrrr�join)r�choicesrr�xs     r�enter_choicer'ds���
�'�����s��
�	��s�x�x��1�2�8�8�:�@�@�B�J�
�}��}�1L���#��m�+�+��]�*�*�����*�$�$��� ���#�#��	�	�
�Y�Y�G�4�q���
�4�
5�}�F�	G�)���	��	��$5s�:B6�C�6	C�Cc��tjd�tjd�tjtj|��tjtjdt|�z��y)Nr	�-)r�infor�len)�texts r�titler-�sI���H�H�R�L��H�H�R�L��H�H�S�X�X�d�^���H�H�S�X�X�c�#�d�)�m�
$�%�c��t|�}tjd�tjd|dzz�tjd|zdz�tjd|dzz�tjd�y)Nr	r)�z| z |)r+rr*)r,r
s  r�headerr1�s]���D�	�A��H�H�R�L��H�H�S�!�A�#�Y���H�H�T�$�Y�t�^���H�H�S�!�A�#�Y���H�H�R�Lr.c� �|sd}t|�S)NzAA page will be printed.
Please load plain paper into the printer.��continue_prompt)�msgr-s  r�load_paper_promptr6�s���R���3��r.c��td�S)NzzLoad the alignment page on the scanner bed and push the 'Scan' or 'Enter' button on the printer to complete the alignment.r3�r.r�load_scanner_for_align_promptr9�s���X�Y�Yr.c��td�S)NzVA page will be printed.
Please load HP Advanced Photo Paper - Glossy into the printer.r3r8r.r�load_photo_paper_promptr;�s���t�u�ur.c���		ttj|dz��j�j	�}|sy|dk(rytj
d��]#t
$rY�iwxYw)NTz+ Press <enter> to continue or 'q' to quit: rFz*Please press <enter> or enter 'q' to quit.)rrrrrrr)�promptr&s  rr4r4�sm��
�	��c�h�h�v�(U�U�V�W�]�]�_�e�e�g�A���
�#�X���	�	�>�?����	��	�s�=A�	A+�*A+c��tj|�}		ttj	|��}|s|�||fS|dk(rd|fS|j
|�}|stjd��Zd|fS#t
$rY�iwxYw)NTrFz,Incorrect input. Please enter correct input.)�re�compilerrrr�searchr)�regexr=�patternr�re_objr&�matchs       r�enter_regexrF�s���
�Z�Z��
�F�
�	��c�h�h�v�&�'�A��]�.� �!�#�#�
�#�X��-�'�'��
�
�a� ����I�I�D�E���Q�w����	��	�s�A4�4	B�?Bc��	tr'ddl}|jd�j�d}n&ddl}|jd�j�d}ddd�}|jd�D]7}|j�}t
|�dk(s�"|d||d<|d||d<�9t|d�t|d�fS#t$rYy	wxYw)
Nrzstty -a)�rows�columns�;�rrHrI)�(�@)	r�
subprocess�	getoutput�
splitlines�commands�splitr+r�	TypeError)rN�ln1rQ�vals�phr&s      r�ttysizerW�s�������&�&�y�1�<�<�>�q�A�C���$�$�Y�/�:�:�<�Q�?�C��t�,���)�)�C�.�	"�B����
�A��1�v��{��q�T��Q�q�T�
��q�T��Q�q�T�
�		"�
�4��<� �#�d�9�o�"6�6�6������s�B
C�
3C�	C
�C
c��eZdZdd�Zdd�Zy)�
ProgressMeterc��d|_||_d|_d|_d|_t�dt
|�z
dz
|_|jd�y)Nrz	\|/-\|/-*r�)	�progressr=�prev_length�spinner�spinner_posrWr+�max_size�update)�selfr=s  r�__init__zProgressMeter.__init__�sM����
�������#�������	�!��s�6�{�2�R�7��
����A�r.c��||_t|j|jzdz�}||jkDr|j}|jdk\rd|_d|_tj
j
d|jz�d|jd|dz
z|j|jd|j|z
z|j|fz}tj
j
|�tj
j�t|�|_|jdzdz|_y)N�d��z%s [%s%s%s] %d%%  %s   rr� )r\rr`r_�sys�stdout�writer]r=r^�flushr+)rbr\r5r&r
s     rrazProgressMeter.update�s�� ��
���
�
��
�
�-��3�4���t�}�}��$�-�-�a��=�=�C�� �D���D�M��
�
����� 0� 0�0�1�%�
�[�[�#�q��s�)�T�\�\�$�2B�2B�%C�
�$�-�-��/�
"�D�M�M�3�
8�
8��	�
�
������
�
�����q�6��� �,�,�q�0�A�5��r.N)z	Progress:�r	)�__name__�
__module__�__qualname__rcrar8r.rrYrY�s���6r.rYc� �eZdZdd�Zd�Zd�Zy)�	FormatterNc�J�||_||_g|_||_||_y�N)�marginr1rH�
max_widths�
min_widths)rbrur1rwrvs     rrczFormatter.__init__�s%����������	�$���$��r.c�:�|jj|�yrt)rHr#)rb�row_datas  r�addz
Formatter.adds���	�	����"r.c	�d�|j�r�t|jd�}|jD]*}t|�|k7s�tjd|z�yt|j�|k7rtjd�g}|jD]B}|jd�}d}|D]}t
|t|��}�|j|��Dg}t|j�D]A\}}d}|jD]}t
|t||��}�|j|��Cd}	|j�Lt�d}	d|	|zzdz}
g|_	|jD]}|jj|
��n-t|j�|k7rtjd�|j�N|	�
t�d}	d	|	|zzdz}g|_|jD]}|jj|��n-t|j�|k7rtjd
�g}g}
t|j||j|�D]V\}}}}t
t
||�t||��}|j|�|
j||jd���Xtj t#|
��}tj%|j'|j��g}|D]}|jdt)|�z��!tj%|j't#|���|jD]&}tj%|j'|���(ytjd
�y)Nrz"Invalid number of items in row: %sz"Invalid number of items in header.rhrrf�
z*Invalid number of items in max col widths.r0z*Invalid number of items in min col widths.)�widthrur)zNo data rows)rHr+rrr1rR�maxr#�	enumeratervrWrw�zip�minrur�
TextFormatter�tupler*�composer)rb�num_cols�r�min_calc_widthsr
�header_parts�	max_widthr&�max_calc_widths�max_screen_width�def_max�def_min�
col_widths�formats�m1�m2�m3�m4�	col_width�	formatter�seps                     r�outputzFormatter.outputsF���9�9��4�9�9�Q�<�(�H��Y�Y�
���q�6�X�%��I�I�B�Q�F�G��
�
�4�;�;��8�+��	�	�>�?� �O��[�[�
2�� �w�w�s�|���	�%�7�A� #�I�s�1�v� 6�I�7� �&�&�y�1�

2�!�O�!�$�+�+�.�
2���1��	����:�A� #�I�s�1�Q�4�y� 9�I�:� �&�&�y�1�
2� $�����&�#*�9�Q�<� ��-�h�6�7��:��"$������4�A��O�O�*�*�7�3�4��t���'�8�3��I�I�J�K����&�#�+�'.�y��|�$��-�h�6�7��:��"$������4�A��O�O�*�*�7�3�4��t���'�8�3��I�I�J�K��J��G�"%�d�o�o��&*�o�o��#H�
L���B��B���B���S��R�[�9�	��!�!�)�,�����d�k�k�J�K�	
L��+�+�E�'�N�;�I��H�H�Y�&�&�t�{�{�3�4��C��
'���
�
�3�s�1�v�:�&�
'�
�H�H�Y�&�&�u�S�z�2�3��Y�Y�
/������*�*�1�-�.�
/�
�I�I�n�%r.)rKNNN)rnrorprcrzr�r8r.rrrrr�s��%�#�I&r.rrrK�Fc��|t|�z
}|tk(rd|dzz|zd|dz|dzzzzS|tk(rd|z|zS|d|zzS)NrhrK)r+�ALIGN_CENTER�ALIGN_RIGHT)�liner}�	alignment�spaces    r�alignr�Xsq���C��I��E��L� ��E�!�G�}�t�#��E�!�G�e�A�g�%�&�'�	'�
�k�	!��5�y�4����c�%�i��r.c�T�|�
t�d}g}|j�}	|d|dd}}|D]H}dt|�z}t|�|z|kDr|j	t|||��|}�A|dz|z}�J|j	t|||��|S#t$r|gcYSwxYw)Nrrrh)rWrR�
IndexErrorr+r#r�)�	paragraphr}r��result�words�current�word�	increments        r�format_paragraphr�fs����}��	�!���
�F��O�O��E���q��5���9����'����D�	�M�	��w�<�)�#�e�+��M�M�%���	�:�;��G��c�k�$�&�G�'��M�M�%���	�2�3��M�����{���s�
B�B'�&B'c���td�tjdd�}d}tddd��}d}t	|�D]Q\}}|||k(r%|jt
|�dz||f�|}�3|jt
|�||f��S|j�|�td	|fzd
||�\}}ntdzd
|�\}}|r||}|Stjd
�|S)NzSELECT PRINTER�	last_used�printer_name)�NumzCUPS Printer�rfre)rf��r1rvrwrzA
Enter number 0...%d for printer (q=quit, <enter>=default: *%d) ?rz+
Enter number 0...%d for printer (q=quit) ?)r1�	user_conf�getrrrrz�strr�r!ri�exit)	�printers�last_used_printer_name�ret�table�
default_indexr&�_�ok�is	         r�
printer_tabler�s��
���&�]�]�;��G��
�C��4�)1�g�
G�E��M��(�#�-���1�!�X�a�[�0��I�I�s�1�v��|�X�a�[�1�2��M��I�I�s�1�v�x��{�+�,�-�
�L�L�N�� ��`�de�gt�cu�u� !�1�m�5���A��J�Q�N�PQ�ST�U���A�	��q�k���J�	������Jr.c	���td�tjdd�}d}|rtddd��}ntdd	d
��}d}i}t	|�D]�\}}|||<||k(rW|r |jt
|�dz|f�n2|jt
|�dz|dj||�f�|}�g|r|jt
|�|f���|jt
|�|dj||�f���|j�|�td
|fzd||�\}	}
ntdzd|�\}	}
|	r||
}|Stjd�|S)Nz
SELECT DEVICEr��
device_uri)r�zScan device URIr�)rf�r�)r�z
Device URIzCUPS Printer(s))rfrere)rfr�r�r�,z@
Enter number 0...%d for device (q=quit, <enter>=default: %d*) ?rz*
Enter number 0...%d for device (q=quit) ?)r1r�r�rrrrzr�r$r�r!rir�)�devices�	scan_flag�last_used_device_urir�r�r��device_indexr&�dr�r�s           r�device_tabler��sy��
�?��$�=�=��l�C��
�C���!;�,4��J���!I�,9�k�S���M��L��'�"�=���1���Q���1�$���	�	�3�q�6�C�<��+�,��	�	�3�q�6�C�<��C�H�H�W�Q�Z�,@�A�B��M���	�	�3�q�6�1�+�&��	�	�3�q�6�1�c�h�h�w�q�z�&:�;�<�=�
�L�L�N�� ��_�cd�fs�bt�t� !�1�m�5���A��I�A�M�q�RS�T���A�	��1�o���J�	������Jr.c��dddid}}}tjr
d||<|dz
}tjr
d||<|dz
}t|�dkDr�t	d�tddd	�
�}t
|j��D]T\}}|dk(r'|jt|�dz|d|df��2|jt|�|d|df��V|j�td|zd|d�\}}|r	||dg}|Sd
g}|S)Nr)�usbzUniversal Serial Bus (USB)r)�netz:Network/Ethernet/Wireless (direct connection or JetDirect))�parzParallel Port (LPT:)zSELECT CONNECTION (I/O) TYPE)r�zConnection Type�Description)rfr��P)rfr|rLr�rz@
Enter number 0...%d for connection type (q=quit, enter=usb*) ? r�)�prop�	net_build�	par_buildr+r1rr�list�itemsrzr�r�r!)r��iosr&r��datar��vals       r�connection_tabler��s)����A�C�Q�a��C��~�~�V��A��	�Q����~�~�0��A��	�Q���
�3�x�!�|��-�.��!J�%0�[�J���C�I�I�K�(�	6�G�A�t��A�v��	�	�3�q�6�C�<��a��$�q�'�:�;��	�	�3�q�6�4��7�D��G�4�5�		6�	�����a�de�e�
�q�!����C���s�8�A�;�-�C�
�J��g���Jr.)r
Nrt)r	r	rm)F)rir?�gr	r�sixextr�sixext.movesrrr!r'r-r1r6r9r;r4rFrW�objectrYrr�
ALIGN_LEFTr�r�r�r�r�r�r�r8r.r�<module>r�s���.�	�����#E�L�:G�8&�� �Y�v�
@� �.�&6�F�6�DV&��V&�t�
������J� �'+�j��2�@)�X"r.

Zerion Mini Shell 1.0