Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.12/site-packages/click/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.12/site-packages/click/__pycache__/_termui_impl.cpython-312.pyc

�

'ٜg�`�	���dZddlZddlZddlZddlZddlZddlZddlmZ	ddl
mZddlm
Z
ddlmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZddlmZddlmZddlmZddlmZej:d�Zej>dk(rdZ dZ!ndZ dZ!Gd�dejDe�Z#d0dejHe%dejLe'ddfd�Z(dejHe%de%dejLe'de'fd�Z)dejHe%de%dejLe'de'fd �Z*d!ejVdejHe%dejLe'ddfd"�Z,Gd#�d$�Z-d1d%e%d&e'd'e'de.fd(�Z/d)e%dejLe0fd*�Z1er/ddl2Z2ejfdejhe.fd+��Z5d,e'de%fd-�Z6yddl7Z7ddl8Z8ejfdejhe.fd.��Z5d,e'de%fd/�Z6y)2z�
This module contains implementations for the termui module. To keep the
import time of Click down, some infrequently used functionality is
placed in this module and only imported as needed.
�N)�gettext)�StringIO)�which)�
TracebackType�)�_default_text_stdout)�CYGWIN)�get_best_encoding)�isatty)�open_stream)�
strip_ansi)�term_len)�WIN)�ClickException)�echo�V�nt�
�
z
[?25lz[?25h
c!�`�eZdZ														d*dejej
edejededededede	d	eje	d
e	dejejejegejefdejed
ejejdeje	dededdf d�Zd+d�Z
dejejedejedejeddfd�Zdej$efd�Zdefd�Zd,d�Zedefd��Zedefd��Zedefd��Zdefd�Zdefd�Zdefd �Zdefd!�Zdefd"�Zd,d#�Z d$eddfd%�Z!d-d$ed&ejeddfd'�Z"d,d(�Z#dej$efd)�Z$y).�ProgressBarN�iterable�length�	fill_char�
empty_char�bar_template�info_sep�show_eta�show_percent�show_pos�item_show_func�label�file�color�update_min_steps�width�returnc���||_||_||_||_||_||_|	|_|
|_|xsd|_|�t�}|�
t�}||_|
|_||_
d|_||_|dk(|_|�ddlm}||d�}|dk(rd}|�A|�t'd��t)j*t(j,t.t1|��}t3|�|_||_d|_g|_||t;j:�x|_|_d|_ d|_!d|_"d|_#d|_$tK|j�|_&d|_'y)N�r)�length_hint���ziterable or length is requiredF)(rrrrrrr r!r"rrr#r$r%�_completed_intervalsr&�	autowidth�operatorr*�	TypeError�t�cast�Iterabler�range�iterr�pos�avg�time�start�last_eta�	eta_known�finished�	max_width�entered�current_itemr�	is_hidden�
_last_line)�selfrrrrrrrrr r!r"r#r$r%r&r*s                 �=/usr/local/lib/python3.12/site-packages/click/_termui_impl.py�__init__zProgressBar.__init__(s`��$#���$���(��� ��
� ��
�(��� ��
�,����+�2��
��<�'�)�D��|��z����	���
� 0���$%��!���
�$��z����>�,� ��2�.�F���|������~�� @�A�A��v�v�a�j�j��m�U�6�]�;�H�#'��>��	�������"$�����%)�Y�Y�[�0��
�T�]�$���#��
�*.���"���+/���#)�$�)�)�#4�4���+/���c�4�d|_|j�|S)NT)r=�render_progress�rAs rB�	__enter__zProgressBar.__enter__ms����������rD�exc_type�	exc_value�tbc�$�|j�y�N)�
render_finish)rArIrJrKs    rB�__exit__zProgressBar.__exit__rs��	
���rDc�p�|jstd��|j�|j�S)N�.You need to use progress bars in a with block.)r=�RuntimeErrorrF�	generatorrGs rB�__iter__zProgressBar.__iter__zs.���|�|��O�P�P������~�~��rDc�*�tt|��SrM)�nextr4rGs rB�__next__zProgressBar.__next__�s���D��J��rDc��|jry|jjt�|jj	�yrM)r?r#�write�	AFTER_BAR�flushrGs rBrNzProgressBar.render_finish�s*���>�>���	�	���	�"��	�	���rDc��|jryt|jt|jxsd�xsdzd�S)N��?r)r;�minr5�floatrrGs rB�pctzProgressBar.pct�s5���=�=���4�8�8�u�T�[�[�%5�A�6�;�!�<�c�B�BrDc��|jsyt|j�tt|j��zS�Ng)r6�sumr_�lenrGs rB�time_per_iterationzProgressBar.time_per_iteration�s,���x�x���4�8�8�}�u�S����]�3�3�3rDc��|j�2|js&|j|j|jz
zSyrb)rr;rer5rGs rB�etazProgressBar.eta�s3���;�;�"�4�=�=��*�*�d�k�k�D�H�H�.D�E�E�rDc���|jrUt|j�}|dz}|dz}|dz}|dz}|dz}|dz}|dkDr|�d|d�d|d�d|d��S|d�d|d�d|d��Sy)N�<�rzd �02�:r))r:�intrg)rAr0�seconds�minutes�hourss     rB�
format_etazProgressBar.format_eta�s����>�>��D�H�H�
�A��"�f�G�
�"�H�A��"�f�G�
�"�H�A���F�E�
�"�H�A��1�u���B�u�R�j��'�"��Q�w�r�l�C�C����1�W�R�L��'�"��>�>�rDc�l�t|j�}|j�|d|j��z
}|S)N�/)�strr5r)rAr5s  rB�
format_poszProgressBar.format_pos�s3���$�(�(�m���;�;�"��Q�t�{�{�m�$�$�C��
rDc�@�t|jdz�d�d�ddS)N�dz 4�%r)rmr`rGs rB�
format_pctzProgressBar.format_pct�s&���d�h�h��n�%�b�)��+�A�B�/�/rDc�F�|j�Rt|j|jz�}|j|z}||j
|j|z
zz
}|S|jr|j|jz}|St|j
|jxsdz�}|jdk7rU|j|ttj|j|jz�dzdz|jz�<dj|�}|S)Nrrg@g�?r))
rrmr`r&rrr;�listre�math�cosr5�join)rA�
bar_length�bar�charss    rB�
format_barzProgressBar.format_bar�s���;�;�"��T�X�X��
�
�2�3�J��.�.�:�-�C��4�?�?�d�j�j�:�&=�>�>�C��
��]�]��.�.�4�:�:�-�C��
�����D�J�J�O�!�<�=�E��&�&�!�+��N�N������$�(�(�T�-D�-D�"D�E��K�c�Q��*�*�%����'�'�%�.�C��
rDc��|j}g}|j�|�
|j}|jr|j|j	��|r|j|j��|jr7|jr+|js|j|j��|j�.|j|j�}|�|j|�|j|j|j�|jj!|�d�zj#�S)N)r"r��info)rrr �appendruryrr:r;rqr!r>rr"r�rr~�rstrip)rAr�	info_bits�	item_infos    rB�format_progress_linez ProgressBar.format_progress_line�s���(�(���	��;�;�"�|�';�#�}�}�,�L��=�=����T�_�_�.�/�����T�_�_�.�/��=�=�T�^�^�D�M�M����T�_�_�.�/����*��+�+�D�,=�,=�>�I��$�� � ��+�
���������(��
�
�*�*�9�5��
��&�(�	rDc�&�ddl}|jrW|j|jk7r=|j|_t	|j|j
|j��yg}|jr�|j}d|_t|j��}td|j�j|z
�}||kr:|jt�|jd|j z�||_||_|j}|j �|j }|jt�|j�}t|�}|j �|j |kr||_|j|�|jd||z
z�dj#|�}||jk7rE||_t	||j
|jd��|j
j%�yy)Nr)r#r$� r)F)r#r$�nl)�shutilr?r@r"rr#r$r-r&rr��max�get_terminal_size�columnsr��
BEFORE_BARr<r~r[)	rAr��buf�	old_width�clutter_length�	new_width�clear_width�line�line_lens	         rBrFzProgressBar.render_progress�s�����>�>����$�*�*�,�"&�*�*����T�Z�Z�d�i�i�t�z�z�B�����>�>��
�
�I��D�J�%�d�&?�&?�&A�B�N��A�v�7�7�9�A�A�N�R�S�I��9�$��
�
�:�&��
�
�3����/�0�!*���"�D�J��j�j���>�>�%��.�.�K��
�
�:���(�(�*���D�>���>�>�!�T�^�^�h�%>�%�D�N��
�
�4���
�
�3�+��0�1�2��w�w�s�|���4�?�?�"�"�D�O���D�I�I�T�Z�Z�E�B��I�I�O�O��#rD�n_stepsc��|xj|z
c_|j� |j|jk\rd|_tj�|jz
dkrytj�|_|jr/tj�|j
z
|jz}n!tj�|j
z
}|jdd|gz|_|jdu|_y)NTr]i����)r5rr;r7r9r8r6r:)rAr��steps   rB�	make_stepzProgressBar.make_steps������G����;�;�"�t�x�x�4�;�;�'>� �D�M��I�I�K�$�-�-�'�3�.���	�	���
�
�8�8��I�I�K�$�*�*�,����8�D��9�9�;����+�D��8�8�B�C�=�D�6�)������D�0��rDr>c���|�||_|xj|z
c_|j|jk\r3|j|j�|j	�d|_yy)aUpdate the progress bar by advancing a specified number of
        steps, and optionally set the ``current_item`` for this new
        position.

        :param n_steps: Number of steps to advance.
        :param current_item: Optional item to set as ``current_item``
            for the updated position.

        .. versionchanged:: 8.0
            Added the ``current_item`` optional parameter.

        .. versionchanged:: 8.0
            Only render when the number of steps meets the
            ``update_min_steps`` threshold.
        Nr)r>r,r%r�rF)rAr�r>s   rB�updatezProgressBar.update)sb�� �#� ,�D���!�!�W�,�!��$�$��(=�(=�=��N�N�4�4�4�5�� � �"�()�D�%�>rDc�.�d|_d|_d|_y)NFT)r:r>r;rGs rB�finishzProgressBar.finishCs����� �����
rDc#�XK�|jstd��|jr|jEd{���y|jD]=}||_|j
dk(r|j
�|��|jd��?|j�|j
�y7�r�w)z�Return a generator which yields the items added to the bar
        during construction, and updates the progress bar *after* the
        yielded block returns.
        rQNrr)	r=rRr?r4r>r,rFr�r�)rA�rvs  rBrSzProgressBar.generatorHs������|�|��O�P�P��>�>��y�y� � ��i�i��$&��!�
�,�,��1��(�(�*������A�� �
�K�K�M�� � �"�
!�s�3B*�B(�A3B*)N�#r�z%(bar)sz  TNFNNNNr�)r'zProgressBar[V])r'NrM)%�__name__�
__module__�__qualname__r0�Optionalr2rrmrt�bool�Callable�TextIOrCrH�Type�
BaseExceptionrrO�IteratorrTrWrN�propertyr_r`rergrqruryr�r�rFr�r�r�rS�rDrBrr's���#'���%���)-��SW�!%�%)�"&� !��!C0��*�*�Q�Z�Z��]�+�C0��
�
�3��C0��	C0�
�C0��
C0��C0��C0��j�j��&�C0��C0��
�
�1�:�:�q�z�z�!�}�o�q�z�z�#��.N�#O�P�C0��z�z�#��C0��j�j����"�C0��z�z�$��C0��C0� �!C0�"
�#C0�J�
��*�*�Q�V�V�M�2�3���:�:�m�,��
�J�J�}�%�	�

�� �!�*�*�Q�-� � �!� ���C�U�C��C�
�4�E�4��4�
��U����

�C�
��C��0�C�0��C��&�c��6+�Z1��1��1�,*�c�*����A��*�$�*�4�
#�1�:�:�a�=�#rDrrSr$r'c�4�t�}|�
t�}ttj�rt|�s
t|||�Stjjdd�xsdj�}|r"trt|||�ryt|||�rytjjd�dvr
t|||�Ststjjd�rt|d|�ryt|d|�ryd	dl}|j!�\}}t
j"|�	t|d|�r	t
j$|�yt|||�t
j$|�S#t
j$|�wxYw)
z2Decide what method to use for paging through text.N�PAGERr)�TERM)�dumb�emacs�os2�more�lessr)rrr�sys�stdin�
_nullpager�os�environ�get�stripr�_tempfilepager�
_pipepager�platform�
startswith�tempfile�mkstemp�close�unlink)rSr$�stdout�	pager_cmdr��fd�filenames       rB�pagerr�jsC��
!�
#�F��~�����#�)�)��F�6�N��&�)�U�3�3��������.�4�"�;�;�=�I����i��E�:��
�	�9�e�
4��	�z�z�~�~�f��!2�2��&�)�U�3�3��s�|�|�&�&�u�-�>��6�5�4�	��)�V�U�+����#�#�%�L�B���H�H�R�L���i���/��	�	�	�(���&�)�U�3�
�	�	�(����	�	�(��s�:
F�F�F�cmdc��t|�}|�yddl}ttj�}|jdd�dj
�}|�R|ddk(rJtjjdd	��d
j|dd���}|sd|d<d}n
d
|vsd|vrd}|j|gd|j|dd��}|j�J�	|D]*}	|st|	�}	|jj|	��,	|jj�		|j#�	y#tt f$rY�%wxYw#t $rYnwxYw�8)z�Page through text by feeding it to another program.  Invoking a
    pager through this might support colors.

    Returns True if the command was found, False otherwise and thus another
    pager should be attempted.
    NFrrsrr+r��LESSr)r��-RT�r�R�replace)�shellr��env�errors�text)r�
subprocess�dictr�r��rsplit�splitr�r~�Popen�PIPEr�r
rYr��OSError�KeyboardInterrupt�wait)
rSr�r$�cmd_absoluter�r��
cmd_detail�
less_flags�cr�s
          rBr�r��sq����:�L�����
�r�z�z�
�C����C��#�B�'�-�-�/�J��}��A��&�0��
�
���v�r�2�3�C�H�H�Z���^�4L�3M�N�
���C��K��E�
�J�
�#��"3��E����	����o�o���
�
	�	�A�
�7�7����	��D��!�$�'��
�G�G�M�M�$��	�	
���
�
���	�
�F�F�H�
���+
�&�'�
��
�� !�	��	��s$�/D2� E�2E�E�	E�Ec�D�t|�}|�yddl}ddl}|j�\}}dj	|�}|st|�}t
tj�}	t|d�d5}
|
j|j|	��ddd�	|j||g�tj|�tj |�y#1swY�HxYw#t$rY�BwxYw#tj|�tj |�wxYw)z�Page through text by invoking a program on a temporary file.

    Returns True if the command was found, False otherwise and thus another
    pager should be attempted.
    NFrr)�wbT)rr�r�r�r~r
r
r�r�rrY�encode�callr�r�r�r�)rSr�r$r�r�r�r�r�r��encoding�fs           rBr�r��s�����:�L�������#�#�%�L�B��
�7�7�9��D���$��� ����,�H�	�X�t�	$�Q�	'�1�	������H�%�&�
(������x�0�1�
	�����
�	�	�(���
(�	'���
��
��	�����
�	�	�(��s0�0!C�C$�C!�$	C0�-C3�/C0�0C3�3,D�streamc�N�|D] }|st|�}|j|��"y)z>Simply print unformatted text.  This is the ultimate fallback.N)r
rY)r�rSr$r�s    rBr�r��s'������d�#�D����T��rDc��eZdZ				d
dejedejejeefdededdf
d�Zdefd�Z	d	eddfd
�Z
dejejdejejfd�Zy)�EditorN�editorr��require_save�	extensionr'c�<�||_||_||_||_yrM)r�r�r�r�)rAr�r�r�r�s     rBrCzEditor.__init__s!��������(���"��rDc���|j�|jSdD]'}tjj|�}|s�%|cStrydD]}t|���|cSy)N)�VISUAL�EDITOR�notepad)zsensible-editor�vim�nano�vi)r�r�r�r�rr)rA�keyr�r�s    rB�
get_editorzEditor.get_editors`���;�;�"��;�;��%�C�������$�B���	�&���6�F��V�}�(��
�7�rDr�c���ddl}|j�}d}|jr9tjj�}|j
|j�	|j|�d|�d�|d��}|j�}|dk7r$ttd�j|����y#t$r+}ttd�j||�	��|�d}~wwxYw)
Nrz "�"T)r�r�z{editor}: Editing failed)r�z{editor}: Editing failed: {e})r��e)
r�r�r�r�r��copyr�r�r�r�_�formatr�)rAr�r�r�r�r��	exit_coder�s        rB�	edit_filezEditor.edit_files�������"��04���8�8��j�j�o�o�'�G��N�N�4�8�8�$�
	�� � �F�8�2�h�Z�q�!9�w�d� �S�A�����I��A�~�$��0�1�8�8��8�G������	� ��1�2�9�9��1�9�M���
��	�s�AB1�1	C%�:&C � C%r�c��ddl}|sd}njt|ttf�r|}nQ|r|j	d�s|dz
}t
r"|j
dd�jd�}n|jd�}|jd|j��\}}	tj|d	�5}|j|�ddd�tj|tjj|�tjj!|�d
z
f�tjj!|�}|j#|�|j$r9tjj!|�|k(r	tj&|�yt)|d�5}|j+�}ddd�t|ttf�rtj&|�Sj-d�j
dd�tj&|�S#1swY��\xYw#1swY�yxYw#tj&|�wxYw)NrrDrz
z	utf-8-sigzutf-8zeditor-)�prefix�suffixr���rb)r��
isinstance�bytes�	bytearray�endswithrr�r�r�r�r��fdopenrY�utime�path�getatime�getmtimerr�r��open�read�decode)	rAr�r��datar��namer��	timestampr�s	         rB�editzEditor.edit3s������D�
��u�i�0�
1��D��D�M�M�$�/�������|�|�D�&�1�8�8��E���{�{�7�+���#�#�9�T�^�^�#�L���D�	����2�t�$������
�%�
�H�H�T�B�G�G�,�,�T�2�B�G�G�4D�4D�T�4J�Q�4N�O�P����(�(��.�I��N�N�4� �� � �R�W�W�%5�%5�d�%;�y�%H��
�I�I�d�O��d�D�!�Q��V�V�X��"��$��	� 2�3��
�I�I�d�O��9�9�[�)�1�1�&�$�?��I�I�d�O�3%�$��""�!��
�I�I�d�O�sI�H0�+H�=B;H0�H0�H$�,H0�! H0�H!�H0�$H-�)H0�0I)NNTz.txt)
r�r�r�r0r�rt�Mappingr�rCr�r�AnyStrrr�rDrBr�r�s���#'�/3�!��
#��
�
�3��
#��Z�Z��	�	�#�s�(�+�
,�
#��	
#�
�
#�
�
#��C���#��$��,-����A�H�H�-�-�!�*�*�Q�X�X�2F�-rDr��urlr��locatec�x�ddl}dtdtfd�}tjdk(r~dg}|r|j	d�|r|j	d�|j	||��td	d
�}	|j
||��j�|j�Str\|r||�}dd
|��g}n8dg}|r|j	d�|j	d�|j	|�	|j|�Stre|r*||�}dtjj|�g}n'dg}|r|j	d�|j	|�	|j|�S	|r*tjj||��xsd}n||�}|j
d|g�}|r|j�Sy#|j�wxYw#t$rYywxYw#t$rYywxYw#t$r/|j!d�r|s|sddl}|j|�YyYywxYw)Nrrr'c�J�ddlm}|jd�r||dd�}|S)Nr)�unquotezfile://�)�urllib.parserr�)rrs  rB�
_unquote_filezopen_url.<locals>._unquote_filefs&��(��>�>�)�$��#�a�b�'�"�C��
rD�darwinrz-Wr�z	/dev/null�w)�stderr�explorerz/select,r8z/WAITr)��cygstartz-w�.zxdg-open)zhttp://zhttps://r)r�rtr�r�r�rr�r�r�rr�r�r	r�r�dirnamer��
webbrowser)	rr�rr�r"�args�nullr�r+s	         rB�open_urlr.cs����3��3���|�|�x���x����K�K�����K�K������M�#�&�'��K��%��	��#�#�D��#�6�;�;�=��J�J�L�	����$�C��(�3�%� 0�1�D��9�D�����G�$��K�K��O��K�K���	��?�?�4�(�(�
����$�C�������� 4�5�D��<�D�����D�!��K�K���	��?�?�4�(�(�
���'�'�/�/�-��"4�5�<��C���$�C����j�#�.�/����6�6�8�O���O
�J�J�L���	��	���	��	�����>�>�1�2�6�$���O�O�C� ���
�sC�5 G�7G#�"G2�4AH�G �#	G/�.G/�2	G>�=G>�3H9�8H9�chc�v�|dk(r
t��|dk(rts
t��|dk(rtr
t��y)N���)r�r�EOFError)r/s rB�_translate_ch_to_excr5�s7��	�V�|��!�!�	�V�|�C��j��	�V�|���j��rDc#�K�d��y�w)Nr+r�r�rDrB�raw_terminalr7�s������s�rc��|rtj}ntj}|�}|dvr
||�z
}t|�|S)N)��à)�msvcrt�getwche�getwchr5)r�funcr�s   rB�getcharr?�sD��@��>�>�D��=�=�D�
�V��
�!�!�
�$�&�L�B��R� ��	rDc#�K�ttj�std�}|j	�}n tjj	�}d}	tj|�}	tj|�|��tj|t
j|�tjj�|�|j�yy#tj|t
j|�tjj�|�|j�wwxYw#t
j$rYywxYw�w)Nz/dev/tty)rr�r�r�fileno�termios�	tcgetattr�tty�setraw�	tcsetattr�	TCSADRAINr�r[r��error)r�r��old_settingss   rBr7r7�s�����
�c�i�i� ��Z� �A�����B����!�!�#�B��A�
	�"�,�,�R�0�L�
��
�
�2�����!�!�"�g�&7�&7��F��
�
� � �"��=��G�G�I�!���!�!�"�g�&7�&7��F��
�
� � �"��=��G�G�I�!���}�}�	��	�sD�AE�D:�/C�AD:�E�AD7�7D:�:E�
E�E�Ec�J�t�5}tj|d�jt	t
j�d�}|r8tt
j�rt
jj|�t|�|cddd�S#1swYyxYw)N� r�)r7r�rrr
r�r�rr�rYr5)rr�r/s   rBr?r?sd��
�^�r�����R��'�'�(9�#�)�)�(D�i�P�B���s�z�z�*��
�
� � ��$� ��$���^�^�s�BB�B"rM)FF)9�__doc__�
contextlibr|r�r�r7�typingr0rr�iorr�r�typesr�_compatrr	r
rrr
rr�
exceptionsr�utilsr�TypeVarrrr�rZ�Genericrr2rtr�r�r�r�r�r�r�r�rmr.r�r5r;�contextmanagerr�r7r?rBrDr�rDrB�<module>rWs7�����	�
��� ����)��&�� ����&��
�A�I�I�c�N���7�7�d�?��J��I��J��I�@#�!�)�)�A�,�@#�F
$�Q�Z�Z��_�$�Q�Z�Z��-=�$��$�N>�!�*�*�S�/�>��>�A�J�J�t�<L�>�QU�>�B#��z�z�#��#�	�#�
�:�:�d��#�
�	#�L�
�H�H��!"���C���9:���D�9I��	��^�^�BD�#�D�T�D�4�D�C�D�N
�S�
�Q�Z�Z�
�%>�
�������!�*�*�S�/����-�d�-�s�-�`������!�*�*�S�/����4�d��s�rD

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists